Searching...
11:39 PM

Get Cursor Position

Code:

Option Explicit

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

'***********************
'THESE TWO FUNCTIONS RETURN THE POSITION ON THE SCREEN
'IN PIXELS, OF THE CURSOR

'EXAMPLE USAGE:

'Private Sub Form_MouseMove(Button As Integer, _
     'Shift As Integer, X As Single, Y As Single)

'    Label1.Caption = "X Screen Position = " & GetXCursorPos
'    Label2.Caption = "Y Screen Position =  " & GetYCursorPos
'End Sub
'***********************************

Public Function GetXCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetXCursorPos = pt.X
End Function

Public Function GetYCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetYCursorPos = pt.Y
End Function

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Back to top!