Re: hWnd of cursor

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 23 Feb 2003 19:51:46 +0700, aku saya <akusaya at gmx.net> wrote:

>
> I want to know what is the hWnd of the current typing cursor
> (only one at a time).
>
> Not only in my application, but also outside of it.
>
> How to get it?
>
> Thanks!
>

The Windows API call you will need is called 'GetGUIThreadInfo'. With this, 
you can get the handle of the foreground (focus) control that has the 
current caret.

Here some details from the Mircosoft SDK...

GetGUIThreadInfo
The GetGUIThreadInfo function retrieves information about the active window 
or a specified graphical user interface (GUI) thread.

BOOL GetGUIThreadInfo(
  DWORD idThread,       // thread identifier
  LPGUITHREADINFO lpgui  // thread information
);
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 Values
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.

Requirements Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.
  Windows 95/98/Me: Included in Windows 98 and later.
  Header: Declared in Winuser.h; include Windows.h.
  Library: Use User32.lib.



The GUITHREADINFO structure contains information about a GUI thread.

typedef struct tagGUITHREADINFO {
    DWORD   cbSize;
    DWORD   flags;
    HWND    hwndActive;
    HWND    hwndFocus;
    HWND    hwndCapture;
    HWND    hwndMenuOwner;
    HWND    hwndMoveSize;
    HWND    hwndCaret;
    RECT    rcCaret;
} GUITHREADINFO, *PGUITHREADINFO;
Members
cbSize Specifies the size of this structure, in bytes. The caller must set 
this to sizeof(GUITHREADINFO). flags Specifies the thread state. This 
member can be one or more of the following values. Value Meaning 
GUI_16BITTASK Windows XP: Represents the thread's application type. This 
bit is set if the thread corresponds to a 16-bit application. 
GUI_CARETBLINKING  Represents the caret's blink state. This bit is set if 
the caret is visible.  GUI_INMENU  Represents the thread's menu state. This 
bit is set if the thread is in menu mode.  GUI_INMOVESIZE  Represents the 
thread's move state. This bit is set if the thread is in a move or size 
loop.  GUI_POPUPMENUMODE  Represents the thread's pop-up menu state. This 
bit is set if the thread has an active pop-up menu.  GUI_SYSTEMMENUMODE  
Represents the thread's system menu state. This bit is set if the thread is 
in a system menu mode.


hwndActive Handle to the active window within the thread. hwndFocus Handle 
to the window that has the keyboard focus. hwndCapture Handle to the window 
that has captured the mouse. hwndMenuOwner Handle to the window that owns 
any active menus. hwndMoveSize Handle to the window in a move or size loop. 
hwndCaret Handle to the window that is displaying the caret. rcCaret A RECT 
structure that describes the caret's bounding rectangle, in client 
coordinates, relative to the window specified by the hwndCaret member.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu