WM_MOUSEHWHEEL message (Windows)

Switch View :
ScriptFree
WM_MOUSEHWHEEL message

Applies to: desktop apps only

Sent to the active window when the mouse's horizontal scroll wheel is tilted or 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_MOUSEHWHEEL                  0x020E

Parameters

wParam

The high-order word indicates the distance the wheel is rotated, expressed in multiples or factors of WHEEL_DELTA, which is set to 120. A positive value indicates that the wheel was rotated to the right; a negative value indicates that the wheel was rotated to the left.

The low-order word indicates whether various virtual keys are down. This parameter can be one or more of the following values.

ValueMeaning
MK_CONTROL
0x0008

The CTRL key is down.

MK_LBUTTON
0x0001

The left mouse button is down.

MK_MBUTTON
0x0010

The middle mouse button is down.

MK_RBUTTON
0x0002

The right mouse button is down.

MK_SHIFT
0x0004

The SHIFT key is down.

MK_XBUTTON1
0x0020

The first X button is down.

MK_XBUTTON2
0x0040

The second X button is down.

 

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 obtain 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 is a multiple of WHEEL_DELTA, which is set to 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 (for example, 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 more frequent messages. You can also choose your scroll granularity and accumulate deltas until it is reached.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Winuser.h (include Windows.h)

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

Community Content

shivmsit
WM_MOUSEHWHEEL event is missing

I am facing issue with trackpad horizontal scrolling. Window does not get WM_MOUSEHWHEEL event if there is no horizontal scroll bar.

How can i make sure that my window recieve WM_MOUSEHWHEEL event irrespective of whether this window have horizontal scrall bar?

Pls suggest any other approach so that window start receiving either WM_MOUSEHWHEEL or WM_HSCROLL. Provided this window program can not have horizontal scroll bar.


Đonny
Constant value
WM_MOUSEHWHEEL = &H20E