Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MouseDown and MouseMove Events

Status
Not open for further replies.

byleth

Programmer
Feb 27, 2004
70
0
0
PT
hi,


I want to move a control at runtime so i've starting by implement the following simple code:


Private Sub label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
IsDragging = True
End Sub


Private Sub panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If IsDragging Then
Label1.Location = New Point(e.X, e.Y)
End If

End Sub


Private Sub label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
IsDragging = False
End Sub



well, the problem is that for some reason, while in mousedown "mode", the rotine doesn't enter the mouseMove event.

is this the way it should be? while in mouseDown can't raise mouseMove?


thanks
 
with that and this modification...



Private Sub label1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
If IsDragging Then
Label1.Location = New Point(Me.ParentForm.MousePosition.X, Me.ParentForm.MousePosition.Y)

End If

End Sub


...it does the trick


thnaks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top