窗体空白区域按下鼠标左键即可任意拖动窗体,不需要拖动标题栏。
Dim MoveScreen As Boolean Dim MousX As Integer Dim MousY As Integer Dim CurrX As Integer Dim CurrY As Integer Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then MoveScreen = True MousX = X MousY = Y End If End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If MoveScreen Then CurrX = Form1.Left - MousX + X CurrY = Form1.Top - MousY + Y Form1.Move CurrX, CurrY End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveScreen = False End Sub
原文地址:https://www.cnblogs.com/chenxiehan/p/12585337.html
时间: 2024-11-13 15:58:14