Export (0) Print
Expand All
Expand Minimize
1 out of 2 rated this helpful - Rate this topic

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 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.

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

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
GetCursorInfo
GetWindowThreadProcessId
GUITHREADINFO
Conceptual
Windows

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.