xoooox
asked on
Return (x,y) values of 6 clicked locations
I have a PictureBox control opened.
Then, here's what I need to do (Instructions in Human Language) :
1. Click on 6 different locations on the PictureBox using my mouse
button
2. Return the X,Y coordinates of each of the 6 locations and store them
in 2 one-dimension arrays namely, Dim x(1 to 6), y(1 to 6) as Integer
Really glad if you could help.
Then, here's what I need to do (Instructions in Human Language) :
1. Click on 6 different locations on the PictureBox using my mouse
button
2. Return the X,Y coordinates of each of the 6 locations and store them
in 2 one-dimension arrays namely, Dim x(1 to 6), y(1 to 6) as Integer
Really glad if you could help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Question for Dalin - why the whole big POINTAPI stuff - you don't need any API calls for this program. Just wondering...
Try the following. If you have questions, let me know.
Regards
Dalin
'1. declaration:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
2. In your picture's Click event, add:
Dim p As POINTAPI
Static clickCount as Integer
If ClickCount = 0 then clickcount = 1
If clickCount >6 then
'Do what you like, reset or just exit
' I am reset it
Clickcount = 1
End if
Call GetCursorPos( p )
x(clickcount) = p.x
y(clickCount)= p.y