1,451
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Public Property Get hwnd() As Long
hwnd = UserControl.hwnd
End Property
Option Explicit
'移动控件
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
Public Sub MoveWindow(ByVal hwnd As Long)
Dim ret As Long
ReleaseCapture
ret = SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
End Sub
Private Sub Command1_Click()
MsgBox UserControl11.Left
End Sub
Private Sub UserControl11_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call MoveWindow(UserControl11.hwnd)
End Sub