Applies to: desktop apps only
Posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
A window receives this message through its WindowProc function.
#define WM_MOUSEMOVE 0x0200
Parameters
- wParam
-
Indicates whether various virtual keys are down. This parameter can be one or more of the following values.
- lParam
-
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return value
If an application processes this message, it should return zero.
Remarks
Use the following code to obtain the horizontal and vertical position:
xPos = GET_X_LPARAM(lParam); yPos = GET_Y_LPARAM(lParam);
You can also use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
See also
- Reference
- GET_X_LPARAM
- GET_Y_LPARAM
- GetCapture
- SetCapture
- Conceptual
- Mouse Input
- Other Resources
- MAKEPOINTS
- POINTS
Send comments about this topic to Microsoft
Build date: 3/6/2012
增加一個WM_MOUSEMOVE消息給一個按鈕,響應函數是彈出一個非模態對話框,
然后執行 ,結果是 ,在鼠標在按鈕上的時候,創建的對話框就會不斷的閃爍,因為其在 不停的被創建和被銷毀的狀態
However I'm looking for official documentation that this is the intended behavior (or not)
This isn't specified in the article
As noted in the GetMessagePos documentation, using LOWORD/HIWORD is wrong since it will not sign-extend negative coordinates for multiple monitor systems. (All of the documentation for mouse messages (WM_MOUSEMOVE, WM_LBUTTONDOWN, etc.) should stress this, just like the GetMessagePos documentation.)
Edit: Actually, I guess since most mouse messages are in client coordinates (whereas GetMessagePos uses screen coordinates), it's not a big deal.
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
Use this instead:
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
WM_LBUTTONUP at http://msdn.microsoft.com/en-us/library/ms645608(VS.85).aspx