VB中IMAGE控件中怎样使图片完整显示?

来源:百度知道 编辑:UC知道 时间:2024/06/06 16:34:32
因为image较小,图片较大,怎样使图片完全显示在小控件中呢?

把Image的Stretch属性设成True。

用PS修改图片
或是
用VB缩放图片
'在窗体上增加下面控件:
' picture1
'image1(在picture1内,stretch=true,同时要装入图片,以便看到效果)
'option1(caption="放大",value=true)
'option2(caption="缩小",value=false)
'option3(caption="还原",value=false)

'在窗体代码区复制下面代码,运行后先选择相应按钮,然后再点击图片,就会看到效果。

'====窗体代码====
Option Explicit
Dim OldTop As Long, OldLeft As Long, OldWidth As Long, OldHeight As Long

Private Sub Form_Load()
With Image1
OldTop = .Top
OldLeft = .Left
OldWidth = .Width
OldHeight = .Height
End With
End Sub

Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim mWidth As Long, mHeight As Long
If Option1.Value = True Then '放大
With Image1
Image1.Move .Left - X * 0.1, .Top - Y * 0.1, .Width * 1.1, .Height * 1.1
End With
End