vb中如何让窗体大小等于加载的图片大小,也就是说原图片多大窗体就多大
4个回答
展开全部
楼上几位,别误导人家,这功能哪还需要用控件啊?
直接把下面代码复制到窗口代码咐斗里,直接搞定!
Private Sub Form_Load()
Me.ScaleMode = 1
Me.Width = Me.Picture.Width / 26.45836 * 15 + Me.Width - Me.ScaleWidth
Me.Height = Me.Picture.Height / 26.45836 * 15 + Me.Height - Me.ScaleHeight
End Sub
=========================================================================
顺便再差宽教你个如何让图片大小随着窗体变的代码:
Private Sub Form_Resize()
On Error Resume Next
Me.AutoRedraw = True
Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 0, 0, Me.Picture.Width / 26.45836 * 15, Me.Picture.Height /虚简亮 26.45836 * 15, vbSrcCopy
End Sub
直接把下面代码复制到窗口代码咐斗里,直接搞定!
Private Sub Form_Load()
Me.ScaleMode = 1
Me.Width = Me.Picture.Width / 26.45836 * 15 + Me.Width - Me.ScaleWidth
Me.Height = Me.Picture.Height / 26.45836 * 15 + Me.Height - Me.ScaleHeight
End Sub
=========================================================================
顺便再差宽教你个如何让图片大小随着窗体变的代码:
Private Sub Form_Resize()
On Error Resume Next
Me.AutoRedraw = True
Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 0, 0, Me.Picture.Width / 26.45836 * 15, Me.Picture.Height /虚简亮 26.45836 * 15, vbSrcCopy
End Sub
追问
这个,我一变化窗体大小,图片大小就跟窗体大小一样了,但是怎么才能在加载的时候就让他两一样呢:?
追答
只加前面这段
Private Sub Form_Load()
Me.ScaleMode = 1
Me.Width = Me.Picture.Width / 26.45836 * 15 + Me.Width - Me.ScaleWidth
Me.Height = Me.Picture.Height / 26.45836 * 15 + Me.Height - Me.ScaleHeight
End Sub
就是加载时就让窗体大小和图片相等了
后面这段的效果是加载后如果调整窗体大小,图片大小会跟着变
Private Sub Form_Resize()
On Error Resume Next
Me.AutoRedraw = True
Me.PaintPicture Me.Picture, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 0, 0, Me.Picture.Width / 26.45836 * 15, Me.Picture.Height / 26.45836 * 15, vbSrcCopy
End Sub
你如果只想能在加载的时候让窗体大小等于图片原始大小只加前面那段就可以了,不要加后面的
展开全部
这样的话你得先把图片加载到一个图片控液戚件中,比如:picture1、友樱image1中。
然后把控件的 picture1.aitosize=ture (image1.stretch=ture)
之后form1的宽高等于控件的。如果不喜欢控件显示,把它设为隐藏。
要代码???吗闹告陵
然后把控件的 picture1.aitosize=ture (image1.stretch=ture)
之后form1的宽高等于控件的。如果不喜欢控件显示,把它设为隐藏。
要代码???吗闹告陵
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Me.Height = Picture1.Top + Picture1.Height + 480
Me.Width = Picture1.Left + Picture1.Width + 210
If Me.Height <= 4620 Then Me.Height = 4620
If Me.Width <= 3015 Then Me.Width = 3015
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
Me.Width = Picture1.Left + Picture1.Width + 210
If Me.Height <= 4620 Then Me.Height = 4620
If Me.Width <= 3015 Then Me.Width = 3015
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
追问
我指的是窗体的picture属性啊
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用image。在调整窗体大小
追问
没别的办法么?
追答
VB里是没有。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询