# 可以呀?!

Posted by 帅帅阿柳 on August 14, 1998 at 23:31:34:

In Reply to: 为何我用程式码来作表单的拖曳可是无法得到预期的效果，为什么呢？？？ posted by jordan on August 13, 1998 at 12:58:11:

加上一点点座标的变换就可以了...

Dim sngSourceX As Single
Dim sngSourceY As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
sngSourceX = X
sngSourceY = Y
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
Me.Move X + Me.Left - sngSourceX, Y + Me.Top - sngSourceY
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
sngSourceX = X
sngSourceY = Y
End If
End Sub

Follow Ups: