VB.NET移动无边框窗体 两种方法

VB.NET移动无边框窗体 两种方法,第1张

概述      '在窗体上覆盖panel控件,如果直接是窗体,选择Form的MouseDown,MouseMove,MouseUp时间即可     Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown   

'在窗体上覆盖panel控件,如果直接是窗体,选择Form的MouseDown,MouseMove,MouseUp时间即可

Private Sub Panel1_MouseDown(ByVal sender As Object,ByVal e As System.windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
Me.bFormDragging = True
Me.oPointClicked = New Point(e.X,e.Y)
End Sub

Private Sub Panel1_MouseMove(ByVal sender As Object,ByVal e As System.windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If Me.bFormDragging Then
Dim oMovetoPoint As Point
oMovetoPoint = Me.PointToScreen(New Point(e.X,e.Y))
oMovetoPoint.Offset(Me.oPointClicked.X * -1,(Me.oPointClicked.Y + Systeminformation.CaptionHeight + Systeminformation.borderSize.Height) * -1)
Me.Location = oMovetoPoint
End If
End Sub

Private Sub Panel1_MouseUp(ByVal sender As Object,ByVal e As System.windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
Me.bFormDragging = False
End Sub

API移动窗体

Declare Function SendMessage lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As IntPtr,_
ByVal wMsg As Integer,_
ByVal wParam As Integer,_
ByVal lParam As Integer) _
As Boolean
Declare Function ReleaseCapture lib "user32" Alias "ReleaseCapture" () As Boolean
Const WM_SYSCOMMAND = &H112
Const SC_MOVE = &HF010&
Const HTCAPTION = 2

Private Sub Form1_MouseDown(ByVal sender As Object,_ ByVal e As System.windows.Forms.MouseEventArgs) _ Handles MyBase.MouseDown ReleaseCapture() SendMessage(Me.Handle,WM_SYSCOMMAND,SC_MOVE + HTCAPTION,0) End Sub

总结

以上是内存溢出为你收集整理的VB.NET移动无边框窗体 两种方法全部内容,希望文章能够帮你解决VB.NET移动无边框窗体 两种方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1281516.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存