VB编程中如何实现图片框显示大图片时能自动出项滚动条?
当前情况Picturebox控件中放置了image控件,实现了能加载图片的功能,但遇到大图片时只能显示部分,如何实现加载大图片时能自动出现滚动条以查看图片?请VB高手赐教...
当前情况 Picturebox控件中放置了 image控件,实现了能加载图片的功能,但遇到大图片时只能显示部分,如何实现加载大图片时能自动出现滚动条以查看图片?请VB高手赐教,代码该如何写?谢谢了!
展开
1个回答
展开全部
Private Sub Command1_Click()
Dim Pic_name As String
Pic_name = App.Path & "\pic\Wal-067.JPG"
HScroll1.Visible = Fals
VScroll1.Visible = False
Image1.Picture = LoadPicture(Pic_name)
Image1.Stretch = False
If Image1.Width > Picture1.Width Then
Image1.Left = 0
HScroll1.Min = 0
HScroll1.Max = Image1.Width - Picture1.Width
HScroll1.Visible = True
Else
Image1.Left = (Picture1.Width - Image1.Width) / 2
End If
Image1.Stretch = False
If Image1.Height > Picture1.Height Then
Image1.Top = 0
VScroll1.Min = 0
VScroll1.Max = Image1.Width - Picture1.Width
VScroll1.Visible = True
Else
Image1.Top = (Picture1.Top - Image1.Top) / 2
End If
End Sub
Private Sub Form_Load()
HScroll1.Visible = Fals
VScroll1.Visible = False
Command1.Caption = "装入图片"
End Sub
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub
Dim Pic_name As String
Pic_name = App.Path & "\pic\Wal-067.JPG"
HScroll1.Visible = Fals
VScroll1.Visible = False
Image1.Picture = LoadPicture(Pic_name)
Image1.Stretch = False
If Image1.Width > Picture1.Width Then
Image1.Left = 0
HScroll1.Min = 0
HScroll1.Max = Image1.Width - Picture1.Width
HScroll1.Visible = True
Else
Image1.Left = (Picture1.Width - Image1.Width) / 2
End If
Image1.Stretch = False
If Image1.Height > Picture1.Height Then
Image1.Top = 0
VScroll1.Min = 0
VScroll1.Max = Image1.Width - Picture1.Width
VScroll1.Visible = True
Else
Image1.Top = (Picture1.Top - Image1.Top) / 2
End If
End Sub
Private Sub Form_Load()
HScroll1.Visible = Fals
VScroll1.Visible = False
Command1.Caption = "装入图片"
End Sub
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询