vb中。我想用picture1代替标题栏移动窗口,但窗口却消失了。我想是它移到了屏幕外,但为什么?下面是代码
Single)IfButton=1ThenxCursor=XyCursor=YEndIfEndSubPrivateSubpicture1_MouseMove(Button...
Single)
If Button = 1 Then
xCursor = X
yCursor = Y
End If
End Sub
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Print X
Call SetWindowPos(Me.hwnd, 1, 10 + Me.Left, 10 + Me.Top, 100, 100, SWP_NOSIZE)
End If
End Sub 展开
If Button = 1 Then
xCursor = X
yCursor = Y
End If
End Sub
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Print X
Call SetWindowPos(Me.hwnd, 1, 10 + Me.Left, 10 + Me.Top, 100, 100, SWP_NOSIZE)
End If
End Sub 展开
2个回答
展开全部
不需要用API:
Option Explicit
Dim xCursor As Long, yCursor As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
xCursor = X: yCursor = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
Me.Move Me.Left - xCursor + X, Me.Top - yCursor + Y
End If
End Sub '
Option Explicit
Dim xCursor As Long, yCursor As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
xCursor = X: yCursor = Y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
Me.Move Me.Left - xCursor + X, Me.Top - yCursor + Y
End If
End Sub '
追问
我之前也是这样。原来问题在坐标系统上
展开全部
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询