



But for some operations, you might need to track the mouse position beyond this point. Capturing Mouse Movement Outside the Windowīy default, a window stops receiving WM_MOUSEMOVE messages if the mouse moves past the edge of the client area. One consequence of this behavior is that the mouse coordinates might not change between WM_MOUSEMOVE messages. For example, if the cursor is positioned over a window, and the user hides the window, the window receives WM_MOUSEMOVE messages even if the mouse did not move.
#CODEVISION RETURN CODE#
Later in this topic, we will look at code that converts between the two units.Ī window can also receive a WM_MOUSEMOVE message if the position of the cursor changes relative to the window. Remember that these coordinates are in pixels, not device-independent pixels (DIPs). The following code gets the mouse coordinates from lParam.
#CODEVISION RETURN PLUS#
The wParam parameter contains a bitwise OR of flags, indicating the state of the other mouse buttons plus the SHIFT and CTRL keys. Use the GET_X_LPARAM and GET_Y_LPARAM macros to unpack the coordinates from lParam. The lowest 16 bits of lParam contain the x-coordinate, and the next 16 bits contain the y-coordinate. The WM_MOUSEMOVE message contains the same parameters as the messages for mouse clicks. You can override this behavior by capturing the mouse, which is described in the next section. By default, WM_MOUSEMOVE goes to the window that contains the cursor.
#CODEVISION RETURN WINDOWS#
When the mouse moves, Windows posts a WM_MOUSEMOVE message.
