vb如何实现:单击图片不放,移动鼠标,窗口跟着移动?
2个回答
展开全部
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
Private Declare Function ReleaseCapture Lib "user32" () As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
展开全部
假设图片在Picture1中,窗体是Form1。
在通用(声明)中打
Dim RX, RY As Single
在Picture1中的MouseDown中打
RX = X
RY = Y
在Picture1的MouseMove中打
Me.Move Me.Left + X - RX, Me.Height + Y - RY
在通用(声明)中打
Dim RX, RY As Single
在Picture1中的MouseDown中打
RX = X
RY = Y
在Picture1的MouseMove中打
Me.Move Me.Left + X - RX, Me.Height + Y - RY
追问
不行!
RX = X
RY = Y
Me.Move Me.Left + X - RX, Me.Height + Y - RY
都是在Picture1的MouseMove?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询