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
展开
 我来答
百度网友bdb9803
2012-04-24 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:53%
帮助的人:1亿
展开全部
不需要用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 '
追问
我之前也是这样。原来问题在坐标系统上
zx001z7d53
2012-04-24 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5679万
展开全部
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
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式