vb中窗口里的UserControl控件怎样拖动?

我现在的情况是UserControl的属性DragMode=0时;MouseMove响应UserControl的属性DragMode=1时;MouseMove不响应怎样能... 我现在的情况是
UserControl的属性DragMode = 0时;MouseMove响应
UserControl的属性DragMode = 1时;MouseMove不响应

怎样能像VB自带的控件那样拖动
Option Explicit

Dim mX As Long, mY As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
mX = X: mY = Y
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
Me.Move Me.Left - mX + X, Me.Top - mY + Y
End If
End Sub

把form换成要移动的控件名称就可以实现移动了。

谢谢!!这个我也知道,原因我找到了,原来是ScoleMode=pixel惹的祸,一拖就消失了.
谁能告诉我当ScoleMode=pixel时,X和Y怎么算
展开
 我来答
ixusi
2010-08-06 · TA获得超过252个赞
知道小有建树答主
回答量:324
采纳率:0%
帮助的人:209万
展开全部
Option Explicit

Dim mX As Long, mY As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
mX = X: mY = Y
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
Me.Move Me.Left - mX + X, Me.Top - mY + Y
End If
End Sub

把form换成要移动的控件名称就可以实现移动了。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式