能在command中实现图片和文字叠加吗? 我想在command中放置图片,但又想在上面显示不同的字,请问除了在做图片的时候叠加文字外,能直接将它caption中的内容和图片叠加到一起吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 很久没碰VB,记得好像是可以。如果不行,可以用API把文字绘到按钮上。 其实很简单,用扩展控件Forms 2.0 Object Librayr中的CommandButton控件,图片和按钮一样大,在图片上打上文字即可(用动态更换的办法,文字可以用GDI+绘制)。 GDI+绘制的貌似不好,因为一旦刷新一下,图片就没有了,你还得重绘,这样会有闪烁感的 经过测试,简单几行即OK了:Option Explicit'Form1上添加一个图片框控件Picture1,一个命令按钮Command1Private Sub Form_Load() Picture1.Picture = LoadPicture("F:\资料\My Pictures\2006Spring2-西湖美景.jpg") Command1.Caption = "我的图片按钮" Picture1.AutoRedraw = True With Picture1.Font .Name = Command1.Caption .Bold = True .Size = 24 End With Picture1.CurrentX = (Picture1.Width - Picture1.TextWidth(Command1.Caption)) / 2 Picture1.CurrentY = (Picture1.Height - Picture1.TextHeight(Command1.Caption)) / 2 Picture1.ForeColor = RGB(255, 255, 255) Picture1.Print Command1.Caption Command1.Caption = "" Set Command1.Picture = Picture1.Image End Sub效果图如下: 这行.Name = Command1.Caption 改成: .Name = "宋体" 的确,使用 Forms 2.0 Object Librayr 中的 CommandButton 控件,可以使这个问题简单化。 【急】excel 中根据cell中的信息触发一个outlook的mail 高手们,只取网页更新内容要怎么做到? vb打包问题! listview 怎么禁止 里面的项目 鼠标拖拽呢 ? 关于flash.ocx控件不能注册的问题! 请问如何让两条消息不会合并 一个小问题?? 窗体名称能不能用宏替换??高手请指点一二,或者有什么其他方法实现? 请高手指教ole @!@急~~~~ 有关添加记录的问题 Sgn(3 > 2)为何返回值为 -1? VB检测TXT文件长度是否变化
Option Explicit
'Form1上添加一个图片框控件Picture1,一个命令按钮Command1
Private Sub Form_Load()
Picture1.Picture = LoadPicture("F:\资料\My Pictures\2006Spring2-西湖美景.jpg")
Command1.Caption = "我的图片按钮"
Picture1.AutoRedraw = True
With Picture1.Font
.Name = Command1.Caption
.Bold = True
.Size = 24
End With
Picture1.CurrentX = (Picture1.Width - Picture1.TextWidth(Command1.Caption)) / 2
Picture1.CurrentY = (Picture1.Height - Picture1.TextHeight(Command1.Caption)) / 2
Picture1.ForeColor = RGB(255, 255, 255)
Picture1.Print Command1.Caption
Command1.Caption = ""
Set Command1.Picture = Picture1.Image
End Sub
效果图如下: