如何在 mfc 中设置大小和透明/清除 CMFCToolBar 按钮和图标? [英] How to set size and Transparent / Clear CMFCToolBar Button and Icon in mfc?

查看:133
本文介绍了如何在 mfc 中设置大小和透明/清除 CMFCToolBar 按钮和图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一些 (CMFCToolBar) 工具栏,并为它们添加了按钮和图标.我在微软官方网站上读到 CMFCToolBar 需要 23x22 按钮大小和 16x15 图标大小(参考:.

I have created some (CMFCToolBar) toolbars and added buttons and icons to them. I read on Microsoft's official website that CMFCToolBar takes 23x22 button size and 16x15 icon size (ref: link).

If I use 16x15 for the icons, then icons appear blurry. This is because the icons are originally with size 16x16. I used the function SetSizes(CSize (23,23), CSize(16,16)) to change icon size but the icons do not appear right:

Is there another way to set icon and button size?


Update

I called the SetSize function before create toolbar but the icon still appear a little blurry:

I want to know if there is a way to set Icon/button Transparent or make it clear like we can set toolbar transparent through TBSTYLE_TRANSPARENT in CreateEx function.

解决方案

SetSizes is a static function that affects the complete library.

It should be called before you create any toolbar or menu object. Best location is in InitInstance of you applicxation.

But my tipp: Use the sizes that are recommended! 16x15 and 23x22....

Transparency can be done with standard 32bit RGB/A bitmaps. If you have a 16 color bitmap you should use RGB(192,192,192) as the standard color for the background. It is automatically replaced with the needed background color.

This has been answered here too.

这篇关于如何在 mfc 中设置大小和透明/清除 CMFCToolBar 按钮和图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆