VB中IMAGE控件中怎样使图片完整显示?
发布网友
发布时间:2022-04-18 07:14
我来回答
共3个回答
热心网友
时间:2022-04-18 08:43
用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 If
If Option2.Value = True Then '缩小
With Image1
Image1.Move .Left + X * 0.1, .Top + Y * 0.1, .Width * 0.9, .Height * 0.9
End With
End If
End Sub
Private Sub Option3_Click() '还原
With Image1
.Left = OldLeft
.Top = OldTop
.Width = OldWidth
.Height = OldHeight
End With
Option1.Value = True
End Sub
热心网友
时间:2022-04-18 10:01
把下面的代码添加进去就可以了!!!
Private Sub Form_Load()
image1.Stretch = True
End Sub
祝你成功!!!
热心网友
时间:2022-04-18 11:36
把Image的Stretch属性设成True。