GetGUIThreadInfo function (winuser.h)
Retrieves information about the active window or a specified GUI thread.
BOOL GetGUIThreadInfo( [in] DWORD idThread, [in, out] PGUITHREADINFO pgui );
The identifier for the thread for which information is to be retrieved. To retrieve this value, use the GetWindowThreadProcessId function. If this parameter is NULL, the function returns information for the foreground thread.
[in, out] pgui
A pointer to a GUITHREADINFO structure that receives information describing the thread. Note that you must set the cbSize member to
sizeof(GUITHREADINFO) before calling this function.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
This function succeeds even if the active window is not owned by the calling process. If the specified thread does not exist or have an input queue, the function will fail.
This function is useful for retrieving out-of-context information about a thread. The information retrieved is the same as if an application retrieved the information about itself.
For an edit control, the returned rcCaret rectangle contains the caret plus information on text direction and padding. Thus, it may not give the correct position of the cursor. The Sans Serif font uses four characters for the cursor:
|Cursor character||Unicode code point|
|CURSOR_USA||0xfff (this is a marker value with no associated glyph)|
To get the actual insertion point in the rcCaret rectangle, perform the following steps.
- Call GetKeyboardLayout to retrieve the current input language.
- Determine the character used for the cursor, based on the current input language.
- Call CreateFont using Sans Serif for the font, the height given by rcCaret, and a width of
zero. For fnWeight, call
SystemParametersInfo(SPI_GETCARETWIDTH, 0, pvParam, 0). If pvParam is greater than 1, set fnWeight to 700, otherwise set fnWeight to 400.
- Select the font into a device context (DC) and use GetCharABCWidths to get the
Bwidth of the appropriate cursor character.
- Add the
Bwidth to rcCaret.left to obtain the actual insertion point.
The function may not return valid window handles in the GUITHREADINFO structure when called to retrieve information for the foreground thread, such as when a window is losing activation.GUITHREADINFO struct are logical coordinates in terms of the window associated with the caret. They are not virtualized into the mode of the calling thread.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winuser.h (include Windows.h)|
|API set||ext-ms-win-ntuser-window-l1-1-1 (introduced in Windows 8.1)|