Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Command1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture 移动控件'
SendMessage Command1(Index).hwnd, &HA1, 2, 0&
End If
End Sub
Private Sub Form_Click()
On Error GoTo endsub
For i = 1 To 5
Load Command1(i) '生成控件
Command1(i).Top = Command1(i - 1).Top
Command1(i).Left = Command1(i - 1).Left + Command1(i - 1).Width
Command1(i).Visible = True
Next
Exit Sub
endsub:
End Sub