这篇文章主要介绍VB.NET如何拖动窗体,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
这是一个使用VB.NET拖动窗体中的拖动无边框的窗体方法,以下为源代码,朋友们可以参考一下
Private oOriginalRegion As
Region = Nothing
' 用于窗体移动
Private bFormDragging As
Boolean = False
Private oPointClicked As Point
Private Sub Form1_MouseDown
(ByVal sender As Object, ByVal
e As System.Windows.Forms.
MouseEventArgs) Handles
MyBase.MouseDown
Me.bFormDragging = True
Me.oPointClicked =
New Point(e.X, e.Y)
End Sub
Private Sub Form1_MouseUp
(ByVal sender As Object, ByVal
e As System.Windows.Forms.
MouseEventArgs) Handles
MyBase.MouseUpMe.bFormDragging = False
End Sub
Private Sub Form1_MouseMove(ByVal
sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
Handles MyBase.MouseMoveIf Me.bFormDragging Then
Dim oMoveToPoint As Point
' 以当前鼠标位置为基础,找出目标位置
oMoveToPoint = Me.PointToScreen
(New Point(e.X, e.Y))' 根据开始位置作出调整
oMoveToPoint.Offset(Me.oPoint
Clicked.X * -1, _(Me.oPointClicked.Y + _
SystemInformation.CaptionHeight + _
SystemInformation.BorderSize.
Height) * -1)' 移动窗体
Me.Location = oMoveToPoint
End If
End Sub
以上是“VB.NET如何拖动窗体”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。