Can someone tell me how (in detail) to take a picture box, draw an X line and a Y line in the middle, then whever you move the mouse in the graph, it show the coordinates? Anything will be helpfull.
Printable View
Can someone tell me how (in detail) to take a picture box, draw an X line and a Y line in the middle, then whever you move the mouse in the graph, it show the coordinates? Anything will be helpfull.
Code:Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Cls
Line (X, 0)-(X, ScaleHeight)
Line (0, Y)-(ScaleWidth, Y)
Caption = X & "," & Y
End Sub
Thanks kedaman, thats pretty cool, but its not quite what im looking for. What i was talking about is two lines (X and Y) in the middle, and the intersection is 0. Then where ever you put the mouse, it will send the coordinates back to a label.
I think this may be what you want:
To draw the axes:
And to track the mouse in the box:Code:Picture1.Line (Picture1.Width / 2, 0)-(Picture1.Width / 2, Picture1.Height)
Picture1.Line (0, Picture1.Height / 2)-(Picture1.Width, Picture1.Height / 2)
Code:Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "X:" & X - (Picture1.Width / 2) & " Y:" & (Picture1.Height / 2) - Y
End Sub
Thats exactly what i was looking for, thank you so much!!!!!
Ok i got that part to work, now when i give the graph two points to make a line, it screws up.
Sorry, I missunderstood you last time. You really shoud chech out the scaleleft/scaletop/scalewidth/scaleheight properties if you're making graphs, they can be pretty useful. You may integrate scaling zoom and movement and graphs always show correct.