How to set size and Transparent / Clear CMFCToolBar Button and Icon in mfc?

1.8k Views Asked by At

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:

image

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:

Image

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.

1

There are 1 best solutions below

6
On BEST ANSWER

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.