I have an application which has two mice devices. One is a trackball and the other is your standard computer mouse. I am using raw input (WM_INPUT) and I am able to identify both computer mice, distinguish between them and know which one sent the mouse message. Now, what I want to do is if i detect (preferably within WM_INPUT) that the trackball moved (MouseMove) I want to prevent the mouse from moving and do something else; currently the trackball does both (my function plus move the mouse cursor). Any ideas on how i can do this?
I have tried in both the WndProc under WM_MOUSEMOVE and WM_INPUT to set the handled flag to true. I have also within the window itself handled the previewmousemove event and set the handled to true but it still the cursor moves when I move the trackball (see code below).
-
private void OnMouseMove(object sender, MouseEventArgs e)
-
{
-
if (TrackBallMessage == true) //set by the WM_INPUT in WndProc
-
{
-
e.Handled = true; //still moves the mouse :(
-
TrackBallMessage = false; //reset our flag.
-
}
-
}
-
-
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
-
{
-
switch (msg)
-
{
-
case WM_INPUT:
-
{
-
if (<message came from trackball>)
-
{
-
handled = true; //this doesn't prevent the mouse move :(
-
TrackBallMessage = true; //tried to signal to mouse move not to do anything, but it still does (global var)
-
<do my function>
-
}
-
}
-
break;
-
-
case WM_MOUSEMOVE:
-
{
-
if (TrackBallMessage == true)
-
{
-
handled = true; //still does a mousemove :(
-
}
-
}
-
break;
-
}
-
-
return IntPtr.Zero;
-
}
-
Is there some way to block this message from moving pass the WM_INPUT stage? or a way to push it out of the message queue so windows thinks that the message has resolved?