Mouse Input
supports two
operations, move & click
Windows
coordinate system (0,0) in upper left corner.
WM_MOUSEMOVE
lParam - low = x, high = y
wParam – button flags
Mouse Button
Constants
|
Value |
Description |
|
MK_LBUTTON |
left
button |
|
MK_MBUTTON |
middle
button |
|
MK_RBUTTON |
right
button |
|
MK_CONTROL |
control
key |
|
MK_SHIFT |
shift key |
case
WM_MOUSEMOVE;
{ // get x,y loc
int
mouseX = (int)LOWORD(lParam);
int
mouseY = (int)HIWORD(lParam);
// which button
int
button = (int)wParam;
// do the right thing
if (button &
MK_LBUTTON) // left button down
// drag something around
else
// something else
} break;
Other events
you can trap:
General
Mouse Button Events
|
Message |
Meaning |
|
WM_LBUTTONDBLCLK |
left
button dbl click |
|
WM_LBUTTONDOWN |
left
button was pressed |
|
WM_LBUTTONUP |
left
button was released |
|
WM_MBUTTONDBLCLK |
middle
button dbl click |
|
WM_MBUTTONDOWN |
middle
button was pressed |
|
WM_MBUTTONUP |
middle
button was released |
|
WM_RBUTTONDBLCLK |
right
button dbl click |
|
WM_RBUTTONDOWN |
right
button was pressed |
|
WM_RBUTTONUP |
right
button was released |
lParam & wParam
are the same as for WM_MOUSEMOVE and so the handler is similar.