1. hWnd of cursor

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!

new topic     » topic index » view message » categorize

2. Re: hWnd of cursor

This is found in the Win32 API help file (found in the archive):

About Carets
--------------

An application uses the CreateCaret function to specify the parameters for a
caret. Windows
forms a caret by inverting the pixel color within the rectangle specified by the
caret's
position, width, and height. The width and height are specified in logical
units; therefore, the
appearance of a caret is subject to the window's mapping mode.

After the caret is defined, an application uses the ShowCaret function to make
the caret
visible. When the caret appears, it automatically begins flashing. To display a
solid caret,
Windows inverts every pixel in the rectangle; to display a gray caret, Windows
inverts every
other pixel; to display a bitmap caret, Windows inverts only the white bits of
the bitmap.
The elapsed time, in milliseconds, required to invert the caret is called the
blink time. An
application can determine the caret's blink time by using the GetCaretBlinkTime
function. If it
is necessary to define a specific blink time, use the SetCaretBlinkTime function
to set the rate
of the blink time to a specified number of milliseconds. The flash time is the
elapsed time, in
milliseconds, required to display, invert, and restore the caret's display. The
flash time of a
caret is twice as much as the blink time.

An application can determine the caret's position by using the GetCaretPos
function. The
position, in client coordinates, is copied to a POINT structure specified by a
parameter in
GetCaretPos. An application can move a caret in a window by using the
SetCaretPos function. A
window can move a caret only if it already owns the caret. SetCaretPos can move
the caret
whether it is visible or not.

Group:

CreateCaret
DestroyCaret
GetCaretBlinkTime
GetCaretPos
HideCaret
SetCaretBlinkTime
SetCaretPos
ShowCaret



----- Original Message -----
From: aku saya <akusaya at gmx.net>
To: EUforum <EUforum at topica.com>
Sent: Sunday, February 23, 2003 7:51 AM
Subject: hWnd of cursor



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!



TOPICA - Start your own email discussion group. FREE!

new topic     » goto parent     » topic index » view message » categorize

3. Re: hWnd of cursor

This is what I think I understand about working with carets.

I believe that the caret doesn't have its own handle.  You operate on it 
through its parent window.  In win32lib it would be handled from some 
event in its parent window with "setHandler()".  Using the API directly 
you use the window messages to work with it, i.e. WM_SETFOCUS.

some caret functions from win32lib.ew:
    xCreateCaret        = registerw32Function(user32, "CreateCaret", 
{C_POINTER, C_POINTER, C_LONG, C_LONG}, C_LONG ),
    xGetCaretBlinkTime  = registerw32Function(user32, 
"GetCaretBlinkTime", {}, C_LONG ),
    xSetCaretBlinkTime  = registerw32Function(user32, 
"SetCaretBlinkTime", {C_LONG}, C_LONG ),
    xDestroyCaret       = registerw32Function(user32, "DestroyCaret", 
{}, C_LONG ),
    xHideCaret          = registerw32Function(user32, "HideCaret", 
{C_POINTER}, C_LONG ),
    xShowCaret          = registerw32Function(user32, "ShowCaret", 
{C_POINTER}, C_LONG ),
    xSetCaretPos        = registerw32Function(user32, "SetCaretPos", 
{C_LONG, C_LONG}, C_LONG ),
    xGetCaretPos        = registerw32Function(user32, "GetCaretPos", 
{C_POINTER}, C_LONG )


aku saya 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!
>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: hWnd of cursor

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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu