Applies to: desktop apps only
Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it.
A window receives this message through its WindowProc function.
#define WM_MOUSEWHEEL 0x020A
Parameters
- wParam
-
The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
The low-order word 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 pointer, relative to the upper-left corner of the screen.
The high-order word specifies the y-coordinate of the pointer, relative to the upper-left corner of the screen.
Return value
If an application processes this message, it should return zero.
Remarks
Use the following code to get the information in the wParam parameter:
fwKeys = GET_KEYSTATE_WPARAM(wParam); zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
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.
The wheel rotation will be a multiple of WHEEL_DELTA, which is set at 120. This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta.
The delta was set to 120 to allow Microsoft or other vendors to build finer-resolution wheels (a freely-rotating wheel with no notches) to send more messages per rotation, but with a smaller value in each message. To use this feature, you can either add the incoming delta values until WHEEL_DELTA is reached (so for a delta-rotation you get the same response), or scroll partial lines in response to the more frequent messages. You can also choose your scroll granularity and accumulate deltas until it is reached.
Note, there is no fwKeys for MSH_MOUSEWHEEL. Otherwise, the parameters are exactly the same as for WM_MOUSEWHEEL.
It is up to the application to forward MSH_MOUSEWHEEL to any embedded objects or controls. The application is required to send the message to an active embedded OLE application. It is optional that the application sends it to a wheel-enabled control with focus. If the application does send the message to a control, it can check the return value to see if the message was processed. Controls are required to return a value of TRUE if they process the message.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
See also
- Reference
- GET_KEYSTATE_WPARAM
- GET_X_LPARAM
- GET_Y_LPARAM
- GET_WHEEL_DELTA_WPARAM
- HIWORD
- LOWORD
- mouse_event
- Conceptual
- Mouse Input
- Other Resources
- GetSystemMetrics
- MAKEPOINTS
- POINTS
- SystemParametersInfo
Send comments about this topic to Microsoft
Build date: 3/6/2012
Copy&Paste error?
adeyblue edit:
It was a part of a section tagged relevant to Windows 95, NT 3.51. Obviously, in one of the drives to remove outmoded content they removed the lead paragraph but not the trailing text. The original text can be seen via the wayback machine: http://web.archive.org/web/20080508181930/http://msdn.microsoft.com/en-us/library/ms645617(VS.85).aspx
private const int MK_LBUTTON = 0x0001;
private const int MK_RBUTTON = 0x0002;
private const int MK_SHIFT = 0x0004;
private const int MK_CONTROL = 0x0008;
private const int MK_MBUTTON = 0x0010;
private const int MK_XBUTTON1 = 0x0020;
private const int MK_XBUTTON2 = 0x0040;
public static MouseButtons GetMouseButtonWParam(int wparam)
{
int mask = LowWord(wparam);
if ((mask & MK_LBUTTON) == MK_LBUTTON) return MouseButtons.Left;
if ((mask & MK_RBUTTON) == MK_RBUTTON) return MouseButtons.Right;
if ((mask & MK_MBUTTON) == MK_MBUTTON) return MouseButtons.Middle;
if ((mask & MK_XBUTTON1) == MK_XBUTTON1) return MouseButtons.XButton1;
if ((mask & MK_XBUTTON2) == MK_XBUTTON2) return MouseButtons.XButton2;
return MouseButtons.None;
}
public static bool IsCtrlKeyPressedWParam(int wparam)
{
int mask = LowWord(wparam);
return (mask & MK_CONTROL) == MK_CONTROL;
}
public static bool IsShiftKeyPressedWParam(int wparam)
{
int mask = LowWord(wparam);
return (mask & MK_SHIFT) == MK_SHIFT;
}
public static int GetXLParam(int lparam) { return LowWord(lparam); }
public static int GetYLParam(int lparam) { return HighWord(lparam); }
public static int LowWord(int word) { return word & 0xFFFF; }
public static int HighWord(int word) { return word >> 16; }