# 用Mouse移动没有TitleBar的Form-(2)

Posted by Bomber on August 04, 1998 at 22:41:36:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
f = X: g = Y
End Sub
我在 心得笔记中有看到该标题，是用ＡＰＩ做的，恰巧我这几天也刚完成
所以贴出来与大家分享，不是用ＡＰＩ函式做的，只是用很普通的MOUSE事件，
程式并不是完美的，但也能作出灌有CPLUS后表单的移动方式．．．，目前的缺
点是移动太快会产生残像，我想这和电脑的速度有些关系吧！？也或许是程式写的
不够好，总之希望各位前辈批评指教．．．

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

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
h = X: i = Y
j = h - f: k = i - g
Form1.Top = Form1.Top + k
Form1.Left = Form1.Left + j
End If
End Sub

Follow Ups: