vb.net

位置:IT落伍者 >> vb.net >> 浏览文章

VB.NET 拖动无边框窗体编程实例


发布日期:2021年11月06日
 
VB.NET 拖动无边框窗体编程实例

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

上一篇:VB.netini文件操作

下一篇:vb.net入门之分组控件:GroupBox控件