|
-
Aug 27th, 2000, 01:27 PM
#1
Thread Starter
Hyperactive Member
How can I get the x an y pos of the mouse?
-
Aug 27th, 2000, 02:13 PM
#2
Use the GetCursorPos and the WindowFromPoint Api functions to get the position of the mouse.
Code:
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
Type POINTAPI
x As Long
y As Long
End Type
Dim P As POINTAPI
K$ = GetCursorPos(P)
J$ = WindowFromPoint(P.x, P.y)
-
Aug 27th, 2000, 02:53 PM
#3
_______
<?>
Code:
'this will show it anywhere on the form but not
'when it's over other controls
'find the mouse position anywhere on screen
'other than over the taskbar if visible
'text1 & text2 (2 textboxes)
'click anywhere on form to unload
Option Explicit
Private Sub Form_Activate()
Me.BorderStyle = 0 'none
Me.WindowState = 2 'max
End Sub
Private Sub Form_Click()
Unload Me
Set Form1 = Nothing
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = X
Text2.Text = Y
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 27th, 2000, 08:04 PM
#4
Try this. Put the following into a Form with a Timer
Code:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim prevX, prevY
Private Sub Timer1_Timer()
Dim PT As POINTAPI
GetCursorPos PT
If PT.x <> prevX Then Print PT.x
If PT.y <> prevY Then Print PT.y
prevX = PT.x: prevY = PT.y
End Sub
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
|