|
-
Feb 4th, 2003, 07:15 AM
#1
Thread Starter
Member
Want to know where is text cursor..?
HELLO EVERBODY,
I want to know how can I find where is the text cursor at any time even outside my application anywhere in windows.
For instance, Say when I was writing this message I saw two cursors. One for mouse. Other at a place where I was writing this message. I wanna know info may be handle, classname of control and application where currently it is?
-
Feb 10th, 2003, 06:38 AM
#2
You can find the mouse Mouse cursors x,y values by by calling the GetCursorPos API
VB Code:
Type PointApi
X as long
Y as long
End Type
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
but i dont know how to get information about the text cursor if that was what u were asking about
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Feb 10th, 2003, 10:39 AM
#3
Frenzied Member
I think you're actually looking for the caret. I don't know how to do what you're looking for, but maybe using "caret" in your search will help you out.
-
Feb 10th, 2003, 11:14 AM
#4
Frenzied Member
Each thread can have it's own caret and only one window in that thread will have the active CARET.
VB Code:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type GUITHREADINFO
cbSize As Long
flags As Long
hWndActive As Long
hwndFocus As Long
hwndCapture As Long
hwndMenuOwner As Long
hwndMoveSize As Long
hwndCaret As Long
rcCaret As RECT
End Type
Private Declare Function GetGUIThreadInfo Lib "user32" (ByVal hThreadId As Long, pGuiThreadInfo As GUITHREADINFO) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Public Function GetActiveCaretHwnd() As Long
Dim gti As GUITHREADINFO
If GetGUIThreadInfo(GetCurrentThread(), gti) Then
GetActiveCaretHwnd = gti.hwndCaret
End If
End Function
-
Feb 10th, 2003, 11:24 AM
#5
Frenzied Member
What about getting its position in a textbox?
-
Feb 10th, 2003, 11:34 AM
#6
Frenzied Member
If the textbox is in your app. then use the SelStart property - otherwise use Sendmessage and send it a EM_GETSEL message...search MSDN for info on this message...
-
Feb 11th, 2003, 10:48 PM
#7
Frenzied Member
-
Mar 23rd, 2003, 07:50 AM
#8
Fanatic Member
you may want to try the GetCaretPos function.
it is very unknown but i use it and it works fine !
it gives you the position of the caret in points. the position on the screen ! not the character index within the editbox.
note that you have to change the points to pixels or twips afterwards if you want to make better use of this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|