In my media player application, I hid the cursor using SetCursor(NULL)
and to make sure that Windows does not reset the cursor state, I handled WM_SETCURSOR
in my WndProc
method.
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM.SETCURSOR:
base.WndProc(ref m);
int lowWord = (m.LParam.ToInt32() << 16) >> 16;
if (lowWord == HTCLIENT && FullScreen)
{
SetCursor(IntPtr.Zero); // hides cursor
m.Result = (IntPtr)1; // return TRUE; equivalent in C++
}
return;
}
}
However when the cursor is in the client area (aka LOWORD(lParam) == HTCLIENT
), WM_SETCURSOR
is never triggered in WndProc
. So I never actually get the WM_SETCURSOR
message when the cursor is in the client area and only get it when LOWORD(lParam) != HTCLIENT
.
However in Spy++, it clearly shows that the application received the WM_SETCURSOR
and WM_MOUSEMOVE
messages.
Where is the message getting lost/handled? What do I have to do in order to receive the WM_SETCURSOR
message in C#?