Question

I have the following WndProc:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM w, LPARAM l)
{
    switch (message)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    case WM_MOUSEMOVE:
            return 0;
    default:
        return DefWindowProc(hWnd, message, w, l);
    }
}

I want to prevent the the mouse from moving, so that I am attempting to discard moving message. The problem is that mouse is still moving. I have tried also WM_NCHITTEST and WM_MOUSEHOVER.

Was it helpful?

Solution

If you are trying to confine the cursor movement, please take a look at the ClipCursor function in the Windows API.

OTHER TIPS

The WM_MOUSEMOVE message is just the window manager telling you that the mouse has moved and if your application wants to do something with that information it can do so. It is not a mechanism where you can intercept mouse movements and cancel them at will.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top