smiler44
08-04-2008, 02:40 PM
I would like to obtain the coordinates of a mouse click or curser location inside a picture box at run time
for example
text1.text = x
text2.text = y
x is from the top and y is from the left. Probably in twips.
I'm using using vb5
thank you in advance for any help
Smiler44
georgedwilkinson
08-04-2008, 03:30 PM
It's been a little while since I've used the MouseMove event in POVB. Doesn't the MouseMove event pass in the x and y coordinates of the cursor?
smiler44
08-05-2008, 01:31 AM
Shortly after posting my question I found the form_mouse down event.
This gives me the x and y coordinates but I now find my question is a bit more complicated. I am scrolling a picture in a picture box and am getting the coordinates of a point within the picture box when I clcik the mouse. This does not take into account that the picture has moved.
I need two sets of coordinates, the mouse coordinates within the picture box which I think I can get and the coordinates of the picture box which may well be negitive numbers. It is now this last bit I am haing trouble with.
One problem afetr another!
georgedwilkinson
08-05-2008, 01:39 AM
You've just exceeded my knowledge base. I'd have to experiment, which is what I suggest you do.
smiler44
08-05-2008, 02:47 AM
George,
thanks. I've been playing and by chance typed in a piece of code that has worked.
I have ended up with
Private Sub InnerPict_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = X 'left
Text2.Text = Y 'top
Text6 = InnerPict.top
Text7 = InnerPict.left
End Sub
text1 and 2 are for the mouse coordinates and text 6 and 7 are for the picture box.
seems as if I dont need text 6 and 7.
I read 3 books trying to get this simple bit of code but they were no help.
Ian