vb中如何是背景图片的大小随着窗体改变?
				
									
					
					
						|  | 
							admin 2014年3月24日 17:34
								本文热度 7502 | 
					
				 
				在窗体上添加一个IMage图像框
在复制这段代码
Private Sub Form_Resize()
Image1.Top = 0
Image1.Left = 0
Image1.Stretch = True
Image1.Height = Me.ScaleHeight
Image1.Width = Me.ScaleWidth
Image1.Picture = Me.Picture
End Sub
运行就可以咯~
该文章在 2014/3/24 17:34:09 编辑过
|  |  | 
| 全部评论3 | 
	|  | admin 2014年3月24日 17:34 
			还是用一个image控件吧,把它的Stretch=True 
然后在Form_resize事件中加入以下代码就行了
 
image1.left=0 
image1.top=0 
image1.width=me.scalewidth 
image1.height=me.scaleheight
   该评论在 2014/3/24 17:34:17 编辑过
 | 
	|  | admin 2014年3月24日 17:34 
			最简单的方法,而且不用借助其他图像控件:
 Private Sub Form_Load()
 Me.AutoRedraw = True
 End Sub
 
 Private Sub Form_Resize()
 Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight
 End Sub
 该评论在 2014/3/24 17:34:27 编辑过
 | 
	|  | admin 2014年3月24日 17:34 
			在VB中我们常用到image控件来做适应窗体大小的图片因为控制控件的大小很容易
 并且image控件有Stretch=True的属性可以设置
 举个例子
 一个form  在里面加入image1控件(不是picture控件)
 image1的图片随便载入一个
 然后代码写成
 Private Sub Form_Load()
 Me.Image1.Stretch = True
 End Sub
 
 Private Sub Form_Resize()
 Me.Image1.Top = 200: Me.Image1.Left = 200
 Me.Image1.Width = Me.Width - 400: Me.Image1.Height = Me.Height - 400
 End Sub
 
 试试看
 该评论在 2014/3/24 17:34:59 编辑过
 |