如何让vb中的一个控件只能上下拖动,不能左右拖动?
记住,拖动一定要圆滑(就是敏感度适中)而且拖动时不能有虚影下面的代码不要发:PrivateSubPicture1_MouseMove(ButtonAsInteger,Sh...
记住,拖动一定要圆滑(就是敏感度适中)而且拖动时不能有虚影
下面的代码不要发:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.top = Y
End sub
一定要是上下拖动啊,不允许左右拖动 展开
下面的代码不要发:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.top = Y
End sub
一定要是上下拖动啊,不允许左右拖动 展开
3个回答
展开全部
试试这段代码
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 Long) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ReturnVal As Long
Dim Yx As Integer
If Button = 1 Then
Xs = ReleaseCapture()
Yx = Picture1.Left
ReturnVal = SendMessage(Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
Picture1.Left = Yx
End If
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.top = Y
End sub
Picture1.top = Y
End sub
追问
都说了不能发那个
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你给出的方法是最简单的,不知道你为什么不想用,但这个方法确实是效率最高的
追问
反正就是不想用,只要你给出可以正常使用的代码,100分就送你,要是你还给出我不让给出的那个代码,或给出了不能正常使用的代码,我就黑你。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询