| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1713 人关注过本帖
标题:鼠标经过图片产生缩放变化
取消只看楼主 加入收藏
sclx88
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2016-7-31
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
鼠标经过图片产生缩放变化
编译错误,而且我觉得这个代码是不是太繁杂了,有没有简化一点的,如果我有很多个图片框都需要这种效果,要怎么搞
程序代码:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Dim i

    If (X >= Picture1.Left) And (X <= Picture1.Left + Picture1.Width) And _
        (Y >= Picture1.Top) And (Y <= Picture1.Top + Picture1.Height) Then _
        Picture1.Height = 5628
        Picture1.Left = 0
        Picture1.Top = 0
        Picture1.Width = 8376
       
    ElseIf (X < Picture1.Left) And (X > Picture1.Left + Picture1.Width) And _
       (Y < Picture1.Top) And (Y > Picture1.Top + Picture1.Height) Then _
        Picture1.Left = Picture1.Left - 300
        Picture1.Top = Picture1.Top - 150
        Picture1.Width = Picture1.Width + 600
        Picture1.Height = Picture1.Height + 300
    End If
End Sub
搜索更多相关主题的帖子: color 图片 而且 
2016-09-06 14:12
sclx88
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2016-7-31
收藏
得分:0 
回复 2楼 xiangyue0510
编译错误
else 没有IF
 ElseIf (X < Picture1.Left) And (X > Picture1.Left + Picture1.Width) And _
       (Y < Picture1.Top) And (Y > Picture1.Top + Picture1.Height) Then _
这句哪里有问题
我看到有大神是这样写的,但是我仿造用不起
程序代码:
Dim s(3) As Single

 
Private Sub Form_Load()
With Image1
    .Stretch = True
    s(0) = .Left
    s(1) = .Top
    s(2) = .Width
    s(3) = .Height
End With
End Sub

 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Image1
    If .Left <> s(0) Then .Move s(0), s(1), s(2), s(3)
End With
End Sub

 
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Image1
    If .Left = s(0) Then .Move .Left - 300, .Top - 150, .Width + 600, .Height + 300
End With
End Sub


[此贴子已经被作者于2016-9-6 17:40编辑过]

2016-09-06 17:35
sclx88
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2016-7-31
收藏
得分:0 
回复 4楼 风吹过b
问题解决了,但是实际效果点都不好用,鼠标指要晃一下才变,我要的效果是指针放上去放大,移开恢复原样,大神帮我看看下面的代码怎么搞一下,我比较喜欢这种简单明了的
程序代码:
Dim s(3) As Single

 
Private Sub Form_Load()
With Image1
    .Stretch = True
    s(0) = .Left
    s(1) = .Top
    s(2) = .Width
    s(3) = .Height
End With
End Sub

 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Image1
    If .Left <> s(0) Then .Move s(0), s(1), s(2), s(3)
End With
End Sub

 
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Image1
    If .Left = s(0) Then .Move .Left - 300, .Top - 150, .Width + 600, .Height + 300
End With
End Sub
2016-09-06 19:13
sclx88
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2016-7-31
收藏
得分:0 
回复 7楼 风吹过b
谢谢大神,果然解决了
2016-09-07 16:24
快速回复:鼠标经过图片产生缩放变化
数据加载中...
 
   



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

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