vb编程中想在窗体中间点击鼠标左键拖动整个窗体在屏幕上移动 编码怎么写呀,求高手指点。

2024-11-23 11:53:14
推荐回答(1个)
回答1:

Dim t As Boolean
Dim tx, ty As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
t = True
tx = X
ty = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If t = True Then
Form1.Top = Y + Form1.Top - ty
Form1.Left = X + Form1.Left - tx
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
t = False
End Sub