-
I want to draw lines in a picture using mouse such that when I press the mouse button the line starts and when I release the button, the line finishes at that point. This is just like drawing lines on a form at design time but I want to do the same at run time. The program should draw as many lines as i wish.
Does anyone know the solution to it? Please explain me how to do it.
Thanks.
-
Here's the code:
Code:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static LineStarted As Boolean, PrevX As Single, PrevY As Single
If LineStarted Then
Picture1.Line (X, Y)-(PrevX, PrevY)
Else
Picture1.PSet (X, Y), vbBlack
PrevX = X
PrevY = Y
End If
LineStarted = Not(LineStarted)
End Sub
Here you click twice on the picture:
Once for the beginning of the line (where it draws a dot
for reference)
And a second time at the other side of the line
Hope it helps,
Bye!
Me
[Edited by V(ery) Basic on 04-22-2000 at 07:17 AM]
-
Thanks for your code. It is the one what I was looking for.
Is there any way to increase the width of the line being drawn and can I store the co-ordinates of all the lines in a file so that whenever I start my program it can redraw all the lines. Storing the data in this manner will consume less space than storing the picture.
Can you please modify you code so the the line is visible when I move the mouse over the picture. If you know then kindly guide me to any demo or tutorial site based on this.
Thanks once again.
Kinjal