急!!在VB.NET中窗口位置调整问题!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/22 12:54:44
当窗体属性FormBorderStyle = Windows.Forms.FormBorderStyle.None时,怎么使用鼠标拖动窗体哦???有大虾知道吗???指点下,最好是代码!!!!!小的很菜,求大家啦~~~~谢谢啦!!!!

'点击窗口的任何位置拖动窗体
Dim ctX As Single, ctY As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ctX = X: ctY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Left = Me.Left + X - ctX
Me.Top = Me.Top + Y - ctY
End If
End Sub