Groups | Blog | Home
all groups > c# > october 2005 >

c# : How do you preprocess WM_MOVING and/or WM_MOVE???


Benny Raymond
10/2/2005 10:48:07 PM
I need to be able to process the message WM_MOVING and WM_MOVE, however
I noticed that the following breakpoint in PreProcessMessage isn't hit
on move (it does get hit when I press alt for instance though). It does
get hit on the WndProc, however I can't return a true here, so it's
worthless for me... Any help would be awesome:

==== start code ====
public const int WM_MOVING = 0x0216;
public const int WM_MOVE = 0x0003;
protected override void WndProc(ref Message m)
{
switch (msg.Msg)
{
case WM_MOVING:
{
Debug.WriteLine("break on this line");
//return true;
break;
}
case WM_MOVE:
{
Debug.WriteLine("break on this line");
//return true;
break;
}
}
base.WndProc(ref m);
}


public override bool PreProcessMessage(ref Message msg)
{
switch (msg.Msg)
{
case WM_MOVING:
{
Debug.WriteLine("break on this line");
return true;
break;
}
case WM_MOVE:
{
Debug.WriteLine("break on this line");
return true;
break;
}
}
return base.PreProcessMessage (ref msg);
}
Nicholas Paldino [.NET/C# MVP]
10/3/2005 1:39:39 PM
Benny,

The documentation for PreProcessMessage states:

PreProcessMessage is called by the application's message loop to preprocess
input messages before they are dispatched. Possible values for the msg
parameter are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.

To that end, that will not be called for mouse movement.

You should be able to overrid the WndProc method. Instead of returning
true though, just return the return value from the base implementation.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Abubakar
10/4/2005 11:37:11 AM
So I guess Pinvoke will help here if he wants to stop the form from moving.

Ab.


"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:#rSZoFEyFHA.624@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button