-
Hi,
I've got a weird problem with the mousedown event on a picturebox.
I'm using the mouse to draw a line on the picturebox while the mousebutton is pressed.
Im saving the startposition (x,y) at mousedown and use the x,y at mousemove to draw the line.
That works fine.
If I start outside this picturebox with mousepressed and move into the box, nothing is shown, so far so good.
But If I'm start anywhere on the menu (mousedown over menu), the line is printed starting
at an old startposition as soon as I move onto the box.
?????????????????????
Does anybody have a clue on that?
-
It appears as though your app, has mistaken the menu for the picture box. Interesting.
Can you clear the (x, y) coordinates on the mouse down click event for the menu? Or Clear it on the mouse down <> Picturebox?
-
Post your code up. As Lee M suggested, maybe you're not clearing it, or if you are, it's not in the right event.
-
Try the following.
Code:
Private px As Single
Private py As Single
Private InBox As Boolean
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
px = X
py = Y
InBox = True
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If InBox = True Then
If Button = 1 Then
Picture1.Line (px, py)-(X, Y)
px = X
py = Y
End If
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
InBox = False
End Sub
-
OK, here's the code:
Karte is the PictureBox
BearDistLine is a LineObject
Code:
Private Sub Karte_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
BearDistLine.X1 = X
BearDistLine.Y1 = Y
End Sub
Private Sub Karte_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
BearDistLine.X2 = X
BearDistLine.Y2 = Y
BearDistLine.Visible = True
End Sub
-
Did my above code work for you?
-
Will try that, Megatron
Thanks
And, I'm did reset my systemclock, you are fast but not THAT fast ;-)