' Win32API Example - GetMouse
'
' Jon Vote
'
' 02/2002
'
' 1) Create a new project. Form1 will be created by default.
' 2) Add a label to the form.
' 3) Paste the following code into Form1.
' --- Begin code for Form1
'Win32API Example - GetMouse
'
'Jon Vote
'
'02/2002
'
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngX As Long
Dim lngY As Long
Call GetMouse(lngX, lngY)
Me.Caption = "Win32API - GetMouse X=" & lngX & " Y=" & lngY
End Sub
Sub GetMouse(MouseX As Long, MouseY As Long)
'**
'** - returns current mouse x and y in
'** - twips
'**
Dim mousexy As POINTAPI
Call GetCursorPos(mousexy)
MouseX = (mousexy.x * Screen.TwipsPerPixelX)
MouseY = (mousexy.y * Screen.TwipsPerPixelY)
End Sub
' --- End code for Form1 ---