469,081 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

Draw line on picture

Hello,

Ive to draw a line on a picture i used this code:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
x1 = z.X
y1 = z.Y
lbl3 = "x1: " & x1
lbl4 = "y1: " & y1
With Line1
.Visible = True
.x1 = X
.y1 = Y
.x2 = X
.y2 = Y
Drawing = True
End With
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Drawing Then
With Line1
.x2 = X
.y2 = Y
End With
End If

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
x2 = z.X
y2 = z.Y
lbl5 = "x2: " & x2
lbl6 = "y2: " & y2
Drawing = False
With Line1
Me.Line (.x1, .y1)-(.x2, .y2)
.Visible = False
End With
End Sub
But i doesnt draw on the picture, only on the form??/
Can someone help me with this??

Thx in advance

Dennis
Jul 17 '05 #1
1 9306
> Ive to draw a line on a picture i used this code:

.....<code snipped>.....

But i doesnt draw on the picture, only on the form??/
Can someone help me with this??


Where is the picture? In a PictureBox that is on the form? If so, then
you have to place the Line control INSIDE of the PictureBox. There are
two ways to do this.

First method... after placing the Line control on the form by
double-clicking it from the ToolBox, cut it from the Form by selecting
it (if not already selected) and then pressing Ctrl+X, then select the
PictureBox and paste the Line control into it by pressing Ctrl+V.

Second method... don't double-click the Line control in the first place;
instead, click on it once in the ToolBox to select it, then click and
drag the mouse directly in the PictureBox to place the Line control
directly within the PictureBox.

Rick - MVP

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dennis | last post: by
3 posts views Thread by ACaunter | last post: by
6 posts views Thread by Brad Shook | last post: by
4 posts views Thread by icek | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.