VB.NET自定义标题栏拖动
发布时间:2020-12-17 07:56:51 所属栏目:百科 来源:网络整理
导读:'首先在form里添加一个panel容器 Dim x1,x2,y1,y2 As Integer '鼠标左键按下后将x1,y1赋值 Private Sub Panel1_MouseDown(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMove.MouseDown If e.Button = Windows.Forms.
'首先在form里添加一个panel容器 Dim x1,x2,y1,y2 As Integer '鼠标左键按下后将x1,y1赋值 Private Sub Panel1_MouseDown(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMove.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then x1 = e.X y1 = e.Y End If End Sub '拖动过程中不断对x2,y2赋值 Private Sub Panel1_MouseMove(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMove.MouseMove If e.Button = Windows.Forms.MouseButtons.Left Then x2 = e.X y2 = e.Y Me.Left = Me.Location.X + (x2 - x1) Me.Top = Me.Location.Y + (y2 - y1) End If End Sub (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |