How do you preprocess WM_MOVING and/or WM_MOVE???

B

Benny Raymond

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);
}
==== end code ====
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
A

Abubakar

So I guess Pinvoke will help here if he wants to stop the form from moving.

Ab.


Nicholas Paldino said:
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]
- (e-mail address removed)

Benny Raymond said:
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);
}
==== end code ====
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top