怎样用vb6.0的commandbutton控件加载大小适合次按钮的图片?

我刚学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
结果按钮还是显示图片的一部分,郁闷呀,哪位帮帮忙……

可以用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
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-07-19
唉,同病相怜呐!我也为这事发愁呢。你试试楼上的代码。
嘿嘿,这个游戏程序做成了可以给我发到邮箱里面吗?我想看看。
邮箱:vwxyzq@163.com

不过,我认为用imagebox代替command也不错,我也这样用过。
因为imagebox的stretch属性可以改变图片大小。
相似回答