你的
Private
Declare
Function
SetWindowPos
Lib
"user32"
(ByVal
HWnd
As
Long,
ByVal
hWndInsertAfter
As
Long,
ByVal
X
As
Long,
ByVal
Y
As
Long,
ByVal
cx
As
Long,
ByVal
cy
As
Long,
ByVal
wFlags
As
Long)
As
Long
只能写(定义)在所有程序的最前面,也就是以下程序可以运行
Private
Declare
Function
SetWindowPos
Lib
"user32"
(ByVal
HWnd
As
Long,
ByVal
hWndInsertAfter
As
Long,
ByVal
X
As
Long,
ByVal
Y
As
Long,
ByVal
cx
As
Long,
ByVal
cy
As
Long,
ByVal
wFlags
As
Long)
As
Long
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.Move
Me.Left
-
ctX
+
X,
Me.Top
-
ctY
+
Y
End
Sub
'拖动Form窗口
Private
Sub
Form_Load()
SetWindowPos
Me.HWnd,
-1,
0,
0,
0,
0,
2
Or
1
End
Sub