J
jcrouse
I use the following three subs to click on a label and reposition it at
runtime:
Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown
myMouseDown = True
mouseX = Cursor.Position.X - Me.Location.X - (lblP1JoyUp.Width / 2)
mouseY = Cursor.Position.Y - Me.Location.Y - (lblP1JoyUp.Height / 2)
End Sub
Private Sub lblP1JoyUp_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(mouseX, mouseY)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
lblP1JoyUp.BorderStyle = BorderStyle.FixedSingle
lblP1JoyUp.Location = New
System.Drawing.Point(Cursor.Position.X - (Me.Location.X + 4) -
(lblP1JoyUp.Width / 2), Cursor.Position.Y - (Me.Location.Y + 50) -
(lblP1JoyUp.Height / 2))
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub lblP1JoyUp_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseUp
lblP1JoyUp.BorderStyle = BorderStyle.None
myMouseDown = False
End Sub
The problem is that if I drag it over top of another label funny things
happen. I seems somewhat randon. Sometimes the label I'm dragging will drop
and the label I moved over will be picked up instead. Sometime labels seem
to jump to another part of the screen. I am looking for a way to lock all of
the controls except for the one that I am dragging.
Thanks,
John
runtime:
Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown
myMouseDown = True
mouseX = Cursor.Position.X - Me.Location.X - (lblP1JoyUp.Width / 2)
mouseY = Cursor.Position.Y - Me.Location.Y - (lblP1JoyUp.Height / 2)
End Sub
Private Sub lblP1JoyUp_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(mouseX, mouseY)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
lblP1JoyUp.BorderStyle = BorderStyle.FixedSingle
lblP1JoyUp.Location = New
System.Drawing.Point(Cursor.Position.X - (Me.Location.X + 4) -
(lblP1JoyUp.Width / 2), Cursor.Position.Y - (Me.Location.Y + 50) -
(lblP1JoyUp.Height / 2))
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub lblP1JoyUp_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseUp
lblP1JoyUp.BorderStyle = BorderStyle.None
myMouseDown = False
End Sub
The problem is that if I drag it over top of another label funny things
happen. I seems somewhat randon. Sometimes the label I'm dragging will drop
and the label I moved over will be picked up instead. Sometime labels seem
to jump to another part of the screen. I am looking for a way to lock all of
the controls except for the one that I am dragging.
Thanks,
John