Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Applications process touch events as a click of the left mouse button, so support for mouse input can be important to your OS design.
The OS usually posts a mouse message to the window that contains the hot spot of the cursor when the mouse event occurs. An application can change this behavior by using the SetCapturefunction to route mouse messages to a specific window. The specified window receives all of the mouse messages until the application calls the ReleaseCapturefunction or calls the SetCapturefunction to specify another capture window, or until the user clicks on a window that another thread created.
When the mouse capture changes, the OS sends a WM_CAPTURECHANGEDmessage to the window that is losing the mouse capture. The lParamparameter of this message specifies a handle to the window that is gaining the mouse capture.
Only the foreground window can capture mouse input. When a background window attempts to capture mouse input, the background window receives messages only for mouse events that occur when the hot spot of the cursor is located within the visible portion of the window.
Capturing mouse input is useful if a window must receive all mouse input, even when the cursor moves outside the window. For example, an application typically tracks the cursor position after the user presses a mouse button down and follows the cursor until the user releases the mouse button. If an application has not captured mouse input and the user releases the mouse button outside the window, the window does not receive the message that indicates that the user released the button.
A thread can use the GetCapturefunction to determine whether one of the windows that the thread created has captured the mouse. If one of the windows that the thread created has captured the mouse, GetCaptureretrieves a handle to the window.