怎样用vb6.0的commandbutton控件加载大小适合次按钮的图片?
我刚学vb正在用vb6.0做个小游戏,想在commandbutton按钮上加两个图片,点击一下按钮出来图片1,再点击一下按钮出来图片2,但是由于图片比按钮大,所以按钮只显...
我刚学vb正在用vb6.0做个小游戏,想在commandbutton按钮上加两个图片,点击一下按钮出来图片1,再点击一下按钮出来图片2,但是由于图片比按钮大,所以按钮只显示图片的一小部分。我想让图片自动缩小到跟按钮同样大,按钮上显示整个图片,按钮大小不变。请问谁又没有办法,请给于指导,最好是详细些的加些代码说明。
谢谢!
我把图片放在image中,再把image是属性stretch设置为true,然后再把image付给Command4.Picture
我代码如下:
Private Sub Command4_Click()
If Command4.Tag = "2" Then
Command4.Tag = "1"
Command4.Picture = Image1
Else
Command4.Tag = "2"
Command4.Picture = Image2
End If
End Sub
结果按钮还是显示图片的一部分,郁闷呀,哪位帮帮忙…… 展开
谢谢!
我把图片放在image中,再把image是属性stretch设置为true,然后再把image付给Command4.Picture
我代码如下:
Private Sub Command4_Click()
If Command4.Tag = "2" Then
Command4.Tag = "1"
Command4.Picture = Image1
Else
Command4.Tag = "2"
Command4.Picture = Image2
End If
End Sub
结果按钮还是显示图片的一部分,郁闷呀,哪位帮帮忙…… 展开
2个回答
展开全部
可以用Image1代替command1
Image1.BorderStyle = 1 '按下状态
Image1.BorderStyle = 0 '松开状态
如果一定要用command 可以这样
Private Sub Command4_Click()
'用Picture2 , Picture3加载图片
Picture2.AutoSize = True
Picture3.AutoSize = True
Picture1.AutoRedraw = True
Picture1.Move Picture1.Left, Picture1.Top, Command4.Width, Command4.Height
If Command4.Tag = "2" Then
Command4.Tag = "1"
'缩小图片
Picture1.PaintPicture Form1.Picture2.Image, 0, 0, Command4.Width, Command4.Height, 0, 0, Picture2.Width, Picture2.Height
Command4.Picture = Picture1.Image
Else
Command4.Tag = "2"
'缩小图片
Picture1.PaintPicture Form1.Picture3.Image, 0, 0, Command4.Width, Command4.Height, 0, 0, Picture3.Width, Picture3.Height
Command4.DownPicture = Picture1.Image '这句是按下时显示的图片
End If
End Sub
Image1.BorderStyle = 1 '按下状态
Image1.BorderStyle = 0 '松开状态
如果一定要用command 可以这样
Private Sub Command4_Click()
'用Picture2 , Picture3加载图片
Picture2.AutoSize = True
Picture3.AutoSize = True
Picture1.AutoRedraw = True
Picture1.Move Picture1.Left, Picture1.Top, Command4.Width, Command4.Height
If Command4.Tag = "2" Then
Command4.Tag = "1"
'缩小图片
Picture1.PaintPicture Form1.Picture2.Image, 0, 0, Command4.Width, Command4.Height, 0, 0, Picture2.Width, Picture2.Height
Command4.Picture = Picture1.Image
Else
Command4.Tag = "2"
'缩小图片
Picture1.PaintPicture Form1.Picture3.Image, 0, 0, Command4.Width, Command4.Height, 0, 0, Picture3.Width, Picture3.Height
Command4.DownPicture = Picture1.Image '这句是按下时显示的图片
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询