Can someone tell me the how to make it so that when the mouse is clicked in a picture box, and held down, it will draw a line wherever the mouse is moved. If you could give me the code, or a link to a tutorial, it would greatly apprciated. Thanks...
Printable View
Can someone tell me the how to make it so that when the mouse is clicked in a picture box, and held down, it will draw a line wherever the mouse is moved. If you could give me the code, or a link to a tutorial, it would greatly apprciated. Thanks...
I think you mean the line is only inside of the picturebox, so here's something: (not tested and no pset)
Dim OldX as integer
Dim OldY as integer
Private Sub Picture1_MouseDown(Button as integer, Shift as integer, X as integer, Y as integer)
If Button <> 1 then Exit sub
OldX=X
OldY=Y
End Sub
Private Sub Picture1_MouseMove(Button as integer, Shift as integer, X as integer, Y as integer)
If Button <> 1 then Exit sub
Picture1.Line (OldX, OldY)-(X,Y)
OldX=X
OldY=Y
End Sub
Hope this is what you searched for. If you want that the picture won't be rubbed away, put Autoredraw on.
I dont think im doing it right, could you go a little more in depth?
Try this:
Code:Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CurrentX = X: CurrentY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Line -(X, Y)
End Sub
Thanks, that was exactly what i was looking for!