How to add icons to MFC ribbon buttons(如何将图标添加到 MFC 功能区按钮)
问题描述
我使用 Visual C++ 2010 创建了一个带有功能区的 MFC 应用程序.我已向此功能区添加按钮,但我不知道如何向这些按钮添加图像.我尝试从项目中编辑 writelarge.bmp 文件,并在这些按钮上设置图像索引,但现在功能区图标看起来非常难看.除了从项目中编辑 writelarge.bmp 文件之外,是否有一种简单的方法可以将图标添加到功能区图像?
I created with Visual C++ 2010 a MFC application with ribbon. I have added buttons to this ribbon, but I do not know how to add images to these buttons. I tried editing writelarge.bmp file from the project, and setting the index of image on these buttons, but now the ribbon icons looks very ugly. Is there an easy way to add icons to ribbon images, other than editing writelarge.bmp file from the project?
推荐答案
您可以为每个 RibbonCategory 仅使用一个文件.
You have the possibility to use only one file for each RibbonCategory.
创建您的 png 文件(例如 32x256)
Create your png file (32x256 for instance)
像资源一样添加文件
始终在资源视图中,选择您的 RibbonCategory 并将大图像"属性设置为您的 PNG 资源标识符(如 IDB_MYMENU_PNG).
Always in the Resource View, select your RibbonCategory and set the "Large Images" property to your PNG resource identifier (like IDB_MYMENU_PNG).
我在使用 bmp 格式时也有很多问题(图像不可见,透明度被删除,...),这就是我推荐 png 格式的原因.
I also have many issues using bmp format (image not visible, transparency deleted, ...) that's why I recommand the png format.
为了在同一类别中使用原始图像和自定义图像,我创建了一个合并两者的 png 文件.
In order to use original and custom images in the same category, I created a png file which is a merge of both.
这篇关于如何将图标添加到 MFC 功能区按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将图标添加到 MFC 功能区按钮


基础教程推荐
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 使用从字符串中提取的参数调用函数 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01