GetGUIThreadInfo Function

Retrieves information about the active window or a specified graphical user interface (GUI) thread.

Syntax

BOOL GetGUIThreadInfo(      
    DWORD idThread,     LPGUITHREADINFO lpgui );

Parameters

idThread
[in] Identifies 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
[out] Pointer to a GUITHREADINFO structure that receives information describing the thread. Note that you must set GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling this function.

Return Value

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.

Microsoft Windows 2000: 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 characterUnicode code point
CURSOR_LTR0xf00c
CURSOR_RTL0xf00d
CURSOR_THAI0xf00e
CURSOR_USA0xfff (this is a marker value with no associated glyph)

To get the actual insertion point in the rcCaret rectangle, perform the following steps.

  1. Call GetKeyboardLayout to retrieve the current input language.
  2. Determine the character used for the cursor, based on the current input language.
  3. 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.
  4. Select the font into a device context (DC) and use GetCharABCWidths to get the B width of the appropriate cursor character.
  5. Add the B width to rcCaret.left to obtain the actual insertion point.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 98, Windows NT 4.0 SP3

See Also

Tags :


Page view tracker