Receiving Mouse Messages
A version of this page is also available for
4/8/2010
Applications on Windows® phones process touch events as a click of the left mouse button, so support for mouse input can be important to your OS design.
The mouse generates an input event when the user moves the mouse, or presses or releases a mouse button. The OS converts mouse input events into messages and posts these messages to the message queue for the appropriate thread. When the OS posts mouse messages faster than a thread can process the messages, the OS discards all but the most recent mouse message.
A window receives a mouse message when a mouse event occurs while the cursor is within the borders of the window or when the window has captured the mouse. The following table shows the messages that the system posts when the user moves the mouse, or presses or releases a mouse button while the cursor is within the client area of a window.
Message | Description |
---|---|
The user double-clicked the left mouse button. |
|
The user pressed the left mouse button. |
|
The user released the left mouse button. |
|
The user pressed the middle mouse button. |
|
The user released the middle mouse button. |
|
The user moved the mouse cursor within the client area of the window. |
|
The user rotated or pressed the mouse wheel. |
|
The user pressed the right mouse button. |
|
The user released the right mouse button. |
The lParam parameter of a mouse message indicates the position of the hot spot of the cursor. The low-order word of lParam indicates the x-coordinate of the hot spot, and the high-order word indicates the y-coordinate. The coordinates are specified in client coordinates. In the client coordinate system, all points on the screen are specified relative to an origin at the upper-left corner of the client area.
The wParam parameter of a mouse message contains flags that indicate the status of the other mouse buttons and the CTRL and SHIFT keys at the time of the mouse event. You can check for these flags when the way that you want to process a mouse message depends on the state of another mouse button or of the CTRL or SHIFT key. The following table shows the possible values for wParam, which you can combine.
Value | Description |
---|---|
MK_CONTROL |
The user pressed the CTRL key. |
MK_LBUTTON |
The user pressed the left mouse button. |
MK_MBUTTON |
The user pressed the middle mouse button. |
MK_RBUTTON |
The user pressed the right mouse button. |
MK_SHIFT |
The user pressed the SHIFT key. |
For more information, see Receiving Double-Click Messages.