博客
关于我
CButton按钮添加图片(Bitmap,Icon)
阅读量:142 次
发布时间:2019-02-27

本文共 642 字,大约阅读时间需要 2 分钟。

在MFC应用中,如何在按钮上嵌入Bitmap图标并添加文字内容,可以按照以下步骤进行操作:

  • 在项目中添加所需的Bitmap资源,确保其ID已为IDB_BITMAP1,并将其作为按钮的背景图标设置。

  • 右键点击按钮,选择"属性",将Bitmap属性设置为True,确保"显示图标"选项已启用。

  • 在对话框的OnInitDialog函数中,检查按钮是否已加载Bitmap图标:

  • if (myBitmapButton.GetBitmap() == NULL){    myBitmapButton.SetBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));}
    1. 接着处理Icon图标资源,确保其ID为IDI_ICON1,并将其设置为按钮的图标属性:

    2. 右键点击按钮,选择"属性",将Icon属性设置为True,Bitmap属性设置为False。

    3. 在对话框的OnInitDialog函数中,检查并加载Icon图标:

    4. if (myIconButton.GetIcon() == NULL){    myIconButton.SetIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON1));}
      1. 如需在按钮上显示文字信息,可先在图片编辑软件中添加文字内容并保存为新的Bitmap文件,随后将其作为按钮的背景图标设置。
      2. 通过以上步骤,可以在MFC应用的按钮上成功嵌入图标和文字内容。

    转载地址:http://zjid.baihongyu.com/

    你可能感兴趣的文章
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    Node.js 文件系统的各种用法和常见场景
    查看>>
    node.js 配置首页打开页面
    查看>>
    node.js+react写的一个登录注册 demo测试
    查看>>
    Node.js安装与配置指南:轻松启航您的JavaScript服务器之旅
    查看>>
    nodejs libararies
    查看>>
    nodejs-mime类型
    查看>>
    nodejs中Express 路由统一设置缓存的小技巧
    查看>>
    Node入门之创建第一个HelloNode
    查看>>
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
    查看>>
    npm和yarn的使用对比
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    NR,NF,FNR
    查看>>
    nrf开发笔记一开发软件
    查看>>
    NSDateFormatter的替代方法
    查看>>