![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
[Source] Getting X And Y Coordinates [VB6.0]
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
Y As Long
End Type
Private Sub Timer1_Timer()
Dim rect As POINTAPI
Call GetCursorPos(rect)
Form1.Cls
x.Caption = "Current X = " & rect.x
Y.Caption = "Current Y = " & rect.Y
End SubAdd an Timer called timer1. Add two labels called x and Y. Set the timer1.interval to 5 Last but not least Put the code in the form. Finito u just made x and y coordinates |
|
|
|
|
|
#2 |
|
Programmer
|
^^Yep.. that does indeed work, but I usually prefer using a function and a with statement to get the job done.. because whenever I use this API.. I have to use it alot :\.. anyways, My favorite way to do it is below.. but his words too
![]() Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
Y As Long
End Type
Private Function GetCursorPosEx() as Pointapi
GetCursorPos GetCursorPosEx
End Function
Private Sub Timer1_Timer()
With GetCursorPosEx
X = "Current X = " & .x
Y = "Current Y = " & .y
End with
end sub |
|
|
|
|
|
#3 |
|
Expert Programmer
|
This code is quite common. No offense though. Might help some new people. Just as a note, I first saw this code in the API guide. If your really into VB, then you should have it. Just google "API Guide".
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|