vb实现 移动垂直滚动条可以放大后缩小图片,可以下拉图片

2024年11月22日 18:52
有2个网友回答
网友(1):

'加picture1\2\3 及VScroll1
Private Sub Form_Load()
Picture2.Visible = False
Picture3.Visible = False
Picture2.AutoRedraw = True
Picture3.Width = Picture1.Width
Picture3.Height = Picture1.Height
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
VScroll1.Max = 10
VScroll1.Min = 0
VScroll1.LargeChange = 1
'Picture1.Picture = LoadPicture("")
Picture3.Picture = Picture1.Picture
End Sub
Private Sub VScroll1_Change()Dim x1 As Single
If VScroll1.Value <> 0 Then
x1 = VScroll1.Value * 0.1
ch_min 1 + x1
Else
x1 = 1
Picture2.Width = Picture1.Width
Picture2.Height = Picture1.Height
Picture1.Picture = Picture3.Picture
Picture2.Picture = Picture3.Picture
End If
Me.Caption = x1 * 100 & "%"
End Sub
Function ch_min(sl As Single)
Picture2.Cls
Picture2.Width = Picture3.Width * sl
Picture2.Height = Picture3.Height * sl
Picture2.PaintPicture Picture3.Image, 0, 0, Picture2.Width, Picture2.Height, 0, 0, Picture1.Width, Picture1.Height
Picture1.Picture = LoadPicture("")
Picture1.PaintPicture Picture2.Image, 0, 0End Function

网友(2):

添加一个图片框,设定属性:图片适应图片框,拉动滚动条改变图片框大小
长时间没用vb了,这些属性你要自己找,我不记得了