Imports SystemDrawing
Imports SystemWindowsForms
******************************************
Private oOriginalRegion As Region = Nothing
用於窗體移動
Private bFormDragging As Boolean = False
Private oPointClicked As Point
******************************************
Private Sub Form_MouseDown(ByVal sender As Object ByVal e As SystemWindowsFormsMouseEventArgs) Handles MyBaseMouseDown
MebFormDragging = True
MeoPointClicked = New Point(eX eY)
End Sub
******************************************
Private Sub Form_MouseUp(ByVal sender As Object ByVal e As SystemWindowsFormsMouseEventArgs) Handles MyBaseMouseUp
MebFormDragging = False
End Sub
******************************************
Private Sub Form_MouseMove(ByVal sender As Object ByVal e As SystemWindowsFormsMouseEventArgs) Handles MyBaseMouseMove
If MebFormDragging Then
Dim oMoveToPoint As Point
以當前鼠標位置為基礎找出目標位置
oMoveToPoint = MePointToScreen(New Point(eX eY))
根據開始位置作出調整
oMoveToPointOffset(MeoPointClickedX * _
(MeoPointClickedY + _
SystemInformationCaptionHeight + _
SystemInformationBorderSizeHeight) * )
移動窗體
MeLocation = oMoveToPoint
End If
From:http://tw.wingwit.com/Article/program/ASP/201311/21755.html