Link to home
Start Free TrialLog in
Avatar of amby
amby

asked on

how to get the state of mouse buttons

I need to know the state of the left mouse button when handling a WM_NCMOUSEMOVE (WM_NCMOUSEUP is not sent after a WM_NCMOUSEDOWN, SetCapture() changes nothing)

how to get the state (through API or not...)
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You may also use GetAsyncKeyState. See the documentation for the difference.

Please note: (I am not sure if it is also true for GetKeyState. You may test it.)

The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling

GetSystemMetrics(SM_SWAPBUTTON)
 
which returns TRUE if the mouse buttons have been swapped.