Concept : When the mouse_down event of picture box picCanvas is triggered, a dot is created.
When mouse_move event is triggered, a line is created to the current coordinates of the mouse.
Private Sub Form_Load() picCanvas.AutoRedraw = True picCanvas.DrawWidth = 2 picCanvas.ForeColor = vbBlue picCanvas.BackColor = vbWhite End Sub
Explaination : Not needed, just the basic properties.(Blue line will be created on a white-backgrounded picture box)
Private Sub picCanvas_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then picCanvas.Line (X, Y)-(X, Y) End If End Sub
Explaination : On holding mouse down, a dot is created, i.e., a line with initial and final coordinates SAME.
Private Sub picCanvas_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then picCanvas.Line -(X, Y) End If End Sub
Explaination : The line is extended till the CURRENT coordinates of the mouse.
I think its clear now, for a working sample, download the ATTACHMENT.
Number of downloads: 1995