كود :
Public Class Form1
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Button1.Capture = False
Dim msg As Message = _
Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
Me.Button1.BackColor = Color.Violet
End Sub
Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Button2.Capture = False
Dim msg As Message = _
Message.Create(Button2.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
Me.Button2.BackColor = Color.Violet
End Sub
Private Sub Button3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Button3.Capture = False
Dim msg As Message = _
Message.Create(Button3.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
Me.Button3.BackColor = Color.Violet
End Sub
Private Sub Button4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Button4.Capture = False
Dim msg As Message = _
Message.Create(Button4.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
Me.Button4.BackColor = Color.Violet
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Button1.Location = New System.Drawing.Point(149, 66)
Me.Button2.Location = New System.Drawing.Point(12, 66)
Me.Button3.Location = New System.Drawing.Point(12, 24)
Me.Button4.Location = New System.Drawing.Point(149, 24)
Me.Button1.BackColor = Color.Empty
Me.Button2.BackColor = Color.Empty
Me.Button3.BackColor = Color.Empty
Me.Button4.BackColor = Color.Empty
End Sub
Private Sub TextBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseDown
If Me.Button1.BackColor = Color.Violet Then
Me.Button1.Location = New System.Drawing.Point(12, 132)
If Me.Button1.Location = New System.Drawing.Point(12, 132) Then
Me.Button1.BackColor = Color.Empty
MsgBox("صح")
TextBox2.Location = New Point(Button1.Left, Button1.Top - Button1.Height)
End If
End If
If Me.Button2.BackColor = Color.Violet Then
Me.Button2.Location = New System.Drawing.Point(12, 132)
If Me.Button2.Location = New System.Drawing.Point(12, 132) Then
Me.Button2.BackColor = Color.Empty
MsgBox("خطأ")
TextBox2.Location = New Point(Button2.Left, Button2.Top - Button2.Height)
End If
End If
If Me.Button3.BackColor = Color.Violet Then
Me.Button3.Location = New System.Drawing.Point(12, 132)
If Me.Button3.Location = New System.Drawing.Point(12, 132) Then
Me.Button3.BackColor = Color.Empty
MsgBox("خطأ")
TextBox2.Location = New Point(Button3.Left, Button3.Top - Button3.Height)
End If
End If
If Me.Button4.BackColor = Color.Violet Then
Me.Button4.Location = New System.Drawing.Point(12, 132)
If Me.Button4.Location = New System.Drawing.Point(12, 132) Then
Me.Button4.BackColor = Color.Empty
MsgBox("خطأ")
TextBox2.Location = New Point(Button4.Left, Button4.Top - Button4.Height)
End If
End If
End Sub
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
If Me.Button1.BackColor = Color.Violet Then
Me.Button1.Location = New System.Drawing.Point(149, 132)
If Me.Button1.Location = New System.Drawing.Point(149, 132) Then
Me.Button1.BackColor = Color.Empty
MsgBox("خطأ")
TextBox1.Location = New Point(Button1.Left, Button1.Top - Button1.Height)
End If
End If
If Me.Button2.BackColor = Color.Violet Then
Me.Button2.Location = New System.Drawing.Point(149, 132)
If Me.Button2.Location = New System.Drawing.Point(149, 132) Then
Me.Button2.BackColor = Color.Empty
MsgBox("صح")
TextBox1.Location = New Point(Button2.Left, Button2.Top - Button2.Height)
End If
End If
If Me.Button3.BackColor = Color.Violet Then
Me.Button3.Location = New System.Drawing.Point(149, 132)
If Me.Button3.Location = New System.Drawing.Point(149, 132) Then
Me.Button3.BackColor = Color.Empty
MsgBox("خطأ")
TextBox1.Location = New Point(Button3.Left, Button3.Top - Button3.Height)
End If
End If
If Me.Button4.BackColor = Color.Violet Then
Me.Button4.Location = New System.Drawing.Point(149, 132)
If Me.Button4.Location = New System.Drawing.Point(149, 132) Then
Me.Button4.BackColor = Color.Empty
MsgBox("خطأ")
TextBox1.Location = New Point(Button4.Left, Button4.Top - Button4.Height)
End If
End If
End Sub
End Class