| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 728 人关注过本帖
标题:如何实现FORM1在激活的情况下用鼠标拖动FORM1上的picture1box?
只看楼主 加入收藏
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
结帖率:85.71%
收藏
已结贴  问题点数:35 回复次数:4 
如何实现FORM1在激活的情况下用鼠标拖动FORM1上的picture1box?
如何实现FORM1在激活的情况下用鼠标拖动FORM1上的picture1Box?
具体见附件
New Folder.rar (82.87 KB)


[ 本帖最后由 yuk_yu 于 2010-1-7 14:06 编辑 ]
搜索更多相关主题的帖子: 拖动 鼠标 
2010-01-07 14:04
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:15 
程序代码:
Private mptx As Single
Private mpty As Single
Private mbDown As Boolean

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mptx = X: mpty = Y
    mbDown = True
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If mbDown Then
        Debug.Print mptx, X, mpty, Y
        Label1.Left = Label1.Left + X - mptx
        Label1.Top = Label1.Top + Y - mpty
    End If
End Sub

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mbDown = False
End Sub
2010-01-07 16:18
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 2楼 bczgvip
谢谢版主回复,我是个菜鸟,我将你的代码写入,但还是不能用鼠标拖动,可以帮我把代码加入试试吗?谢谢
2010-01-07 17:38
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:20 
程序代码:
Private mptx As Single
Private mpty As Single
Private mbDown As Boolean

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mptx = X: mpty = Y
    mbDown = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If mbDown Then
        Debug.Print mptx, X, mpty, Y
        Picture1.Left = Picture1.Left + X - mptx
        Picture1.Top = Picture1.Top + Y - mpty
    End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mbDown = False
End Sub
2010-01-07 17:55
yuk_yu
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:334
专家分:134
注 册:2009-3-16
收藏
得分:0 
回复 4楼 bczgvip
谢谢版主,完全符合我的要求!感激....
2010-01-08 08:55
快速回复:如何实现FORM1在激活的情况下用鼠标拖动FORM1上的picture1box?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.065240 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved