7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
在通用节加上这两句:
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Sub Lab_title_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Call ReleaseCapture
Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 1, 0 '在这里加上这句
End If
End Sub
'保存坐标
Private Sub Lab_title_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' 保存坐标代码...
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim r As Long
Dim i As Long
On Error Resume Next
If Button = 1 Then
i = ReleaseCapture()
If i > 0 Then
r = SendMessage(Form1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
'在这里保存你需要的数据
MsgBox ("X=" & X & " " & "Y=" & Y)
End If
End If
End Sub
MsgBox ("X=" & X & " " & "Y=" & Y)
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 HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Form_Mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim r As Long
Dim i As Long
On Error Resume Next
If Button = 1 Then
i = ReleaseCapture()
If i > 0 Then
r = SendMessage(Form1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print X, Y
End Sub