Private Sub Label3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label3.MouseDown
If flag Then
flag = False
Dim x As Integer
Dim y As Integer
x = Label3.Left
y = Label3.Top
Label3.Left = Label1.Left
Label3.Top = Label1.Top
Label1.Left = Label2.Left
Label2.Top = Label1.Top
Label2.Left = x
Label2.Top = y
End If
End Sub
Private Sub Label2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseDown
If flag Then
flag = False
Dim x As Integer
Dim y As Integer
Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
If draging = False Then……
[/Quote]
Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
If draging = False Then
draging = True
MousePos2 = New Point(MousePosition.X - Left - Button2.Left, MousePosition.Y - Top - Button2.Top)
MakeRect()
End If
End Sub
Private Sub MakeRect()
DragRect = New Rectangle(Left + MousePos2.X, Top + MousePos2.Y, Width - Button2.Width, Height - Button2.Height - TitleHeight)
End Sub
Private Sub Button2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
If draging Then
If MousePosition.X < DragRect.Left Then
Button2.Left = 0
ElseIf MousePosition.X > DragRect.Right Then
Button2.Left = Me.Width - Button2.Width
Else
Button2.Left = MousePosition.X - Left - MousePos2.X
End If
If MousePosition.Y < DragRect.Top Then
Button2.Top = 0
ElseIf MousePosition.Y > DragRect.Bottom Then
Button2.Top = Height - Button2.Height - TitleHeight
Else
Button2.Top = MousePosition.Y - Top - MousePos2.Y
End If
End If
End Sub