How do i capture the mouse position and write it into a label?
Printable View
How do i capture the mouse position and write it into a label?
You must use GetCursorPos
'Put this on your module page
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long
'On your form page
Private Sub Command1_click()
Dim Coord as POINTAPI
GetCursorPos Coord 'get the cursor position
Debug.Print "X coord : " & Coord.x 'Show the x position
Debug.Print "Y coord : " & Coord.y 'Show the y position
End Sub
Enjoy !
I'm drawn back with vb3.0...there has to be a way to do it with user.dll, i tried rewriting yours but i get a duplicate procedure when it tries to call the function. Any ideas.
OOppss !!
I have missed "Public".
The right syntax is :
Public Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long
Re Enjoy!
That still wont work. "User32" is still for 32-bit platforms. Try changing it to
OrCode:Declare Function GetCursorPos Lib "user.dll" (lpPoint As POINTAPI) As Long
Code:Declare Function GetCursorPos Lib "user16.dll" (lpPoint As POINTAPI) As Long