VB放大缩小图片与图片的滚动显示

时间:2024-10-16 11:22:11

1、“图片放大”对应command1,“图片缩小”对应command2,在frame1中放置image1、vscroll1、hscroll1,在vscroll1与hscroll1的交接处放置command3。

2、运行的效果:

VB放大缩小图片与图片的滚动显示

3、具体参考代码‘为了例子的简易,设置image1的衡痕贤伎stretch设置为true,设置刚加载的image1的height为4000、widt茑霁酌绡h为4500,滚动条的单击进度为4,图片放大缩小倍数为2成Private Sub Form_Load() Image1.Picture = LoadPicture("1.jpg") VScroll1.Visible = False HScroll1.Visible = False Command3.Visible = False VScroll1.Max = 4000 VScroll1.LargeChange = 4000 / 4 VScroll1.SmallChange = 4000 / 4 HScroll1.Max = 4500 HScroll1.LargeChange = 4500 / 4 HScroll1.SmallChange = 4500 / 4End SubPrivate Sub Command1_Click() Image1.Height = Image1.Height * 1.2 Image1.Width = Image1.Width * 1.2 If Image1.Height > 4000 Then VScroll1.Visible = True HScroll1.Visible = True Command3.Visible = True End IfEnd SubPrivate Sub Command2_Click() Image1.Height = Image1.Height * 0.8 Image1.Width = Image1.Width * 0.8 If Image1.Height < 4000 Then VScroll1.Visible = False HScroll1.Visible = False Command3.Visible = False End IfEnd SubPrivate Sub VScroll1_Change()new_height = Image1.Heightnext_height = new_height - 4000Image1.Top = -(VScroll1.Value / 4000) * next_heightEnd SubPrivate Sub VScroll1_Scroll()new_height = Image1.Heightnext_height = new_height - 4000Image1.Top = -(VScroll1.Value / 4000) * next_heightEnd SubPrivate Sub hScroll1_Change()new_width = Image1.Widthnext_width = new_width - 4500Image1.Left = -(HScroll1.Value / 4500) * next_widthEnd SubPrivate Sub hScroll1_Scroll()new_width = Image1.Widthnext_width = new_width - 4500Image1.Left = -(HScroll1.Value / 4500) * next_widthEnd Sub

© 手抄报圈