SetCapture

This function sets the pen capture to the specified window belonging to the current thread. After a window has captured the pen, all pen input is directed to that window. Only one window at a time can capture the pen.

At a Glance

Header file: Winuser.h
Windows CE versions: 1.0 and later

Syntax

HWND SetCapture(HWND hWnd);

Parameters

hWnd

[in] Handle to the window in the current thread that is to capture the mouse.

Return Values

The handle of the window that had previously captured the mouse indicates success. NULL indicates that there is no such window.

Remarks

Only the foreground window can capture the mouse. When a background window attempts to do so, the window receives messages only for mouse events that occur when the cursor hot spot is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground.

When the window no longer requires all mouse input, the thread that created the window should call the ReleaseCapture function to release the mouse.

This function cannot be used to capture mouse input meant for another process.

See Also

GetCapture, ReleaseCapture, WM_CAPTURECHANGED