vb imagebox

来源:百度知道 编辑:UC知道 时间:2024/07/11 01:29:44
如何用imagebox使图片打击的时候放大,再次打击的时候缩小!
用click事件吗?具体怎么做,有那位能教一下~~~
宽有了,但是长不合适,Image1.Height 不知道怎样才能按原来比例显示
应该用load事件载入启始长宽,然后再弄~~~

Private Sub Form_Load()
pWidth = Image1.Width
pHeight = Image1.Height
Ptop = Image1.Top
Pleft = Image1.Left
Image1.Stretch = True
End Sub
Private Sub Image1_Click()
If pWidth < 3000 Then
Image1.Width = 5000
Image1.Width = 5000
Else
Image1.Width = pWidth
Image1.Height = pHeight
End If
End Sub
为什么再次单击的时候图片不能复原了?

If pWidth < 3000 Then 这里错了,应该改成image.width
但是改好后,再次单击连图像都不见了

Private Sub Form_Load()
pWidth = Image1.Width
pHeight = Image1.Height
这里取值没取到吗?

Option Explicit
Dim pWidth As Long '如果要不同过程中传递同一变量的值,在所有事件之前定义为全局变量
Dim pHeight As Long
'Dim pTop As Long '如果单纯是放大或缩小,不用记录image的初始位置
'Dim pLeft As Long
Dim flag As Boolean '让单击image在放大和缩小中循环,flag=true为放大,flag=false为缩小

Private Sub Form_Load()
pWidth = Image1.Width
pHeight = Image1.Height
'pTop = Image1.Top
'pLeft = Image1.Left
Image1.Stretch = True
flag = True
End Sub
Private Sub Image1_Click()
If flag Then '放大尺寸建议不要用绝对数值来表示,改用相对数值
Image1.Width = 2 * pWidth
Image1.Height = 2 * pHeight
Else
Image1.Width = pWidth
Image1.Height = pHeight
End If
flag = Not flag
End Sub

这样改试试。
==================
Option Explicit
Dim pWidth As Long
Dim pHeight As Long
Dim pTop As Long
Dim pLeft As Long
Private Sub Form_Load()
Image1.Stretch = True
pWidth = Image1.Width
pHeight = Image1.Height
pTop