- Device drivers process mouse and keyboard interrupts and place the resultant event notifications in a systemwide queue known as the raw input queue.
- A dedicated thread owned by the operating system monitors the raw input queue and transfers each message that shows up there to the appropriate thread message queue.
- Win32's asynchronous input model solves this problem by using the raw input queue as a temporary holding buffer and moving input messages to thread message queues at the earliest opportunity.
-
Client-Area Mouse Messages
Message Sent When WM_LBUTTONDOWN The left mouse button is pressed. WM_LBUTTONUP The left mouse button is released. WM_LBUTTONDBLCLK The left mouse button is double-clicked. WM_MBUTTONDOWN The middle mouse button is pressed. WM_MBUTTONUP The middle mouse button is released. WM_MBUTTONDBLCLK The middle mouse button is double-clicked. WM_RBUTTONDOWN The right mouse button is pressed. WM_RBUTTONUP The right mouse button is released. WM_RBUTTONDBLCLK The right mouse button is double-clicked. WM_MOUSEMOVE The cursor is moved over the window's client area. int nButtonCount = ::GetSystemMetrics (SM_CMOUSEBUTTONS) ;
-
If pairing is essential, a program can "capture" the mouse on receipt of a button-down message and release it when a button-up message arrives. -
For a CS_DBLCLKS-style window, two rapid clicks of the left mouse button over the window's client area produce the following sequence of messages:
WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCLK WM_LBUTTONUP
Applications that process single and double clicks of the same button typically select an object on the first click and take some action upon that object on the second click. -
As the mouse is moved, the window under the cursor receives a flurry of WM_MOUSEMOVE messages reporting the latest cursor position.
-
Message-Map Macros and Message Handlers for Client-Area Mouse Messages
Message Message-Map Macro Handling Function WM_LBUTTONDOWN ON_WM_LBUTTONDOWN OnLButtonDown WM_LBUTTONUP ON_WM_LBUTTONUP OnLButtonUp WM_LBUTTONDBLCLK ON_WM_LBUTTONDBLCLK OnLButtonDblClk WM_MBUTTONDOWN ON_WM_MBUTTONDOWN OnMButtonDown WM_MBUTTONUP ON_WM_MBUTTONUP OnMButtonUp WM_MBUTTONDBLCLK ON_WM_MBUTTONDBLCLK OnMButtonDblClk WM_RBUTTONDOWN ON_WM_RBUTTONDOWN OnRButtonDown WM_RBUTTONUP ON_WM_RBUTTONUP OnRButtonUp WM_RBUTTONDBLCLK ON_WM_RBUTTONDBLCLK OnRButtonDblClk WM_MOUSEMOVE ON_WM_MOUSEMOVE OnMouseMove -
The nFlags Parameter
Mask Meaning If Set MK_LBUTTON The left mouse button is pressed. MK_MBUTTON The middle mouse button is pressed. MK_RBUTTON The right mouse button is pressed. MK_CONTROL The Ctrl key is pressed. MK_SHIFT The Shift key is pressed.
if( 1 == nFlags & MK_LBUTTON ){ //do std }
-
When a WM_RBUTTONUP message is passed to the system for default processing,
Windows places a WM_CONTEXTMENU message in the message queue.
Programming Windows with MFC - Capter 3. Mouse and keybord
最新推荐文章于 2010-08-10 11:17:00 发布