Reputation: 312
So, I was reading the WinApi documentation for the callback function of a low-level mouse hook and I got confused about the WPARAM parameter passed to this function.
From the Documentation about the callback function:
wParam [in]
Type: WPARAM
The identifier of the mouse message. This parameter can be one of the following messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_RBUTTONDOWN, or WM_RBUTTONUP.
This only mentions WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_RBUTTONDOWN and WM_RBUTTONUP.
But in the Documentation about the MSLLHOOKSTRUCT structure (used with low-level mouse hooks), other messages are also mentioned:
mouseData
Type: DWORD
If the message is WM_MOUSEWHEEL, the high-order word of this member is the wheel delta. The low-order word is reserved. 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. One wheel click is defined as WHEEL_DELTA, which is 120.
If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released, and the low-order word is reserved. This value can be one or more of the following values. Otherwise, mouseData is not used.
Are those messages also passed in the WPARAM parameter?
Upvotes: 0
Views: 470
Reputation: 6289
Are those messages also passed in the WPARAM parameter?
Yes.
For example, if you want to handle the X button messages, they are posted to your application using WM_XBUTTONDOWN
and WM_XBUTTONUP
. The low-order word of wParam indicates which X button is down (if any).
In addition, please refer Responding to Mouse Clicks
The WM_XBUTTONDOWN and WM_XBUTTONUP window messages apply to both XBUTTON1 and XBUTTON2. The wParam parameter indicates which button was clicked.
UINT button = GET_XBUTTON_WPARAM(wParam);
if (button == XBUTTON1)
{
// XBUTTON1 was clicked.
}
else if (button == XBUTTON2)
{
// XBUTTON2 was clicked.
}
Upvotes: 2