Собственно воть ответ : Код | Public Class Form1 Private blnMoving As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer
Private Sub From1_MouseDown(ByVal sendler As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then blnMoving = True MouseDownX = e.X MouseDownY = e.Y End If End Sub
Private Sub From1_MouseUp(ByVal sendler As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Left Then blnMoving = False End If End Sub
Private Sub From1_MouseMove(ByVal sendler As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If blnMoving Then Dim temp As Point = New Point temp.X = Me.Location.X + (e.X - MouseDownX) temp.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = temp
End If End Sub End class
|
Принцип работы очень прост: при нажатии левой кнопки мыши в форме и передвижении мышки форма перемещается... |