G
Greg
Please help, how in VBA PROGRAM move the caret to the location of the cursor
the given code does not work:
Public Declare Function GetActiveWindow _
Lib "user32" () As Long
Public Declare Function GetCursorPos _
Lib "user32" _
(pp As POINT) As Boolean
Public Declare Function ScreenToClient _
Lib "user32" _
(ByVal hwnd As Long, pp As POINT) As Boolean
Public Declare Function SetCaretPos _
Lib "user32" _
(ByVal x As Integer, ByVal y As Integer) As Boolean
Public Type POINT
x As Long
y As Long
End Type
'-------------------
sub SetCur()
Dim screen As POINT, q as Boolean
'get WORD descriptor
hwnd = GetActiveWindow
'get cursor position
q = GetCursorPos(screen)
' transforming screen coordinates to client
q = ScreenToClient(hwnd, screen)
' trying to move the caret-> don't working !!!!!!!!!!!
q = SetCaretPos(screen.x, screen.y)
end sub
the given code does not work:
Public Declare Function GetActiveWindow _
Lib "user32" () As Long
Public Declare Function GetCursorPos _
Lib "user32" _
(pp As POINT) As Boolean
Public Declare Function ScreenToClient _
Lib "user32" _
(ByVal hwnd As Long, pp As POINT) As Boolean
Public Declare Function SetCaretPos _
Lib "user32" _
(ByVal x As Integer, ByVal y As Integer) As Boolean
Public Type POINT
x As Long
y As Long
End Type
'-------------------
sub SetCur()
Dim screen As POINT, q as Boolean
'get WORD descriptor
hwnd = GetActiveWindow
'get cursor position
q = GetCursorPos(screen)
' transforming screen coordinates to client
q = ScreenToClient(hwnd, screen)
' trying to move the caret-> don't working !!!!!!!!!!!
q = SetCaretPos(screen.x, screen.y)
end sub