option explicit
dim tX as single
dim tY as singel
private sub Control_mousedown(button as integer,shift as integer,x as single,y as single)
if button=vbleftbutton then
tx=x
ty=y
endif
end sub
private sub control_mousemove(button as integer,shift as integer,x as single,y as single)
if button=vbleftbutton then
if abs(x-tx)>15 or abs(y-ty)>15 then
control.move control.left+x-tx,control.top+y-ty
endif
endif
end sub
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 Long) As Long
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Command1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End If
End Sub
'移动 command1 希望对你有点用
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 Const WM_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const HTCAPTION = 2
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Command1.hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0
End If
End Sub