GetGUIThreadInfo function
Retrieves information about the active window or a specified GUI thread.
Syntax
BOOL WINAPI GetGUIThreadInfo( _In_ DWORD idThread, _Inout_ LPGUITHREADINFO lpgui );
Parameters
- idThread [in]
-
Type: DWORD
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.
- lpgui [in, out]
-
Type: LPGUITHREADINFO
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.
Return value
Type: Type: BOOL
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.
Remarks
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_LTR | 0xf00c |
| CURSOR_RTL | 0xf00d |
| CURSOR_THAI | 0xf00e |
| 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, callSystemParametersInfo(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.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Reference
- GetCursorInfo
- GetWindowThreadProcessId
- GUITHREADINFO
- Conceptual
- Windows