|
-
Feb 14th, 2003, 02:18 PM
#1
Thread Starter
Member
Getting Caret's Position
Using the win32 API calls GetCaretPos and ClientToScreen with a POINTAPI structure is not returning the right values for the screen posistion of the caret. It also only updates when the window is moved.... heres the code:
GetCaretPos Pt
ClientToScreen hWnd, Pt
Text1.Text = Pt.X ' Update
Text2.Text = Pt.Y
What am I doing wrong? I need screen coords, not client.
-
Feb 14th, 2003, 02:31 PM
#2
You need to pass the handle to the window containing the caret, not the form, i.e.
VB Code:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim tPOINT As POINTAPI
Call GetCaretPos(tPOINT)
Call ClientToScreen(Text1.hwnd, tPOINT)
Caption = "X: " & tPOINT.x & " - Y:" & tPOINT.y
End Sub
-
Feb 14th, 2003, 02:43 PM
#3
Thread Starter
Member
-
Feb 14th, 2003, 03:11 PM
#4
Thread Starter
Member
I need to be able to get the caret position from other apps. How could I go about getting the handles for each child window in an app? I need help using the EnumChildWindows API call.
-
Feb 14th, 2003, 10:15 PM
#5
Registered User
What about the FindWindow / FindWindowEx API calls?
s.
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
|