GetFocus

This function retrieves the handle to the keyboard focus window associated with the thread that called the function.

At a Glance

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

Syntax

HWND GetFocus(void);

Return Values

The handle to the window with the keyboard focus indicates success. NULL indicates that the calling thread’s message queue does not have an associated window with the keyboard focus.

Remarks

Even if GetFocus returns NULL, another thread’s queue may be associated with a window that has the keyboard focus.

Use the GetForegroundWindow function to retrieve the handle to the window with which the user is currently working. You can associate your thread’s message queue with the windows owned by another thread by using the AttachThreadInput function.

See Also

GetActiveWindow, GetCapture, SetFocus, WM_KILLFOCUS, WM_SETFOCUS