加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

简单图片按钮的实现

发布时间:2020-12-17 08:11:13 所属栏目:百科 来源:网络整理
导读:VB的标准命令按钮CommandButton可以实现图片按钮,并且按钮文字可以居中。 Option Explicit'Form1上添加一个图片框控件Picture1,一个命令按钮Command1Private Sub Form_Load() Picture1.Picture = LoadPicture("F:资料My Pictures2006Spring2-西湖美景.jp

VB的标准命令按钮CommandButton可以实现图片按钮,并且按钮文字可以居中。

Option Explicit
'Form1上添加一个图片框控件Picture1,一个命令按钮Command1
Private Sub Form_Load()
    
   Picture1.Picture = LoadPicture("F:资料My Pictures2006Spring2-西湖美景.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


效果图如下:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读