博客
关于我
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/

    你可能感兴趣的文章
    Project Euler Problem 12: Highly divisible triangular number
    查看>>
    ProjectEuler 2
    查看>>
    projection介绍及EPSG:4326和EPSG:3857的投射转换
    查看>>
    project打开文件时,显示无法识别此文件格式?
    查看>>
    Prometheus + Grafana on Kubernetes部署
    查看>>
    prometheus + grafana进行服务器资源监控
    查看>>
    Prometheus Alertmanager 告警配置详解
    查看>>
    Prometheus Grafana 展示平台
    查看>>
    Prometheus pushgateway使用详解
    查看>>
    Prometheus 云原生 - Prometheus 数据模型、Metrics 指标类型、Exporter 相关
    查看>>
    Prometheus 云原生 - 基于 file_sd、http_sd 实现 Service Discovery
    查看>>
    Prometheus 云原生 - 微服务监控报警系统 (Promethus、Grafana、Node_Exporter)部署、简单使用
    查看>>
    Prometheus 云原生 - 监控 Linux、MySQL、Redis、RabbitMQ、Docker、SpringBoot 3.x
    查看>>
    Prometheus 介绍
    查看>>
    Prometheus 安全配置详解
    查看>>
    prometheus 安装node_exporter, node_exporter 安装最新版 普罗米修思安装监控服务器client
    查看>>
    Prometheus 安装部署实战
    查看>>
    prometheus 持久化存储方案
    查看>>
    Prometheus 监控系统企业级实战
    查看>>
    Prometheus 监控系统简介
    查看>>