Transparent icons for RibbonButton at runtime

Add-in Express™ Support Service
That's what is more important than anything else

Transparent icons for RibbonButton at runtime
 
Bart Van Bossche


Guest


Hi,

We have old *.ini-files that were used by a macro to create commandbars for Word.
These files contain integer that are equal to the old face id's of those Office Icons.

We are now trying to create a Ribbon Tab for our company that reads these ini-files and creates the according ribbontabs.
Everything works great except for the icons of the buttons.
If we select a number of face id's and add them to an imageList at design time, the transparency works (we extracted the icons with a macro and have two bmp for each icon, the picture and the mask). In our program, we have an imagelist with all the picture and a second imagelist with all the mask. In the create of our addin, we programmatically add a picture and the according mask to the imagelist that our buttons use. When we try this, we get nice transparent icons for our ribbon buttons.

The problem is that there are 32400 possible face id's and we have no idea which id's our clients have chosen for their own bars. When you try to add 32400 different icons to an imagelist at design time, we get an error, I guess an imagelist can't contain that much images in design time.
So we created one large bmp that contains all the masked icons in a row. When we use this bmp instead of the imagelist, the size of our dll is a lot smaller which is more ideal for updates. We read all the ini-files and cut the appropiate icons from our large bmp and add them to the imagelist of our ribbon tab. When we use this, our icons are better rendered then when we added the same icons at design time, the only problem is that our background is white and not transparent. If we change the background of the bmp to clFuchsia and use that color as our background for our mask, this is changed again into white and not transparent.

The settings of the imagelist for our ribbon tabbon was the same for both cases, but the result was different.
Design time:
- not as many possible icons
- not well rendered (pixely pictures instead of rounded pictures, one of our most frequent used icons couldn't be recognized)
+ transparent icons
Run time:
+ a lot of possible icons
+ well rendered
- non transparent icons, but always a white background

EDIT: I created a Manager to change our ini files on a more easy way and there I use the same method to get the same icons so our clients can just click on an icon to select it for that button. In that manager, the created button are transparent. So I guess it's not a problem with my code on how I add those parts of my large bmp into my imagelist...

Does anyone have a solution for this?
Posted 09 Jan, 2014 09:39:29 Top
Bart Van Bossche


Guest


I could work around this if I could detect the color of the Office Ribbon somehow and then set the bkColor of my imageList to that color, but I can't find anywhere if it's possible to detect this color...?
Posted 09 Jan, 2014 10:36:22 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Bart,

Still this looks like a problem in your code. Some simple mistake say wrong color depth or getting icons from wrong positions. If you can send us a sample project, we will try to help.

Bart Van Bossche writes:
I could work around this if I could detect the color of the Office Ribbon somehow and then set the bkColor of my imageList to that color, but I can't find anywhere if it's possible to detect this color...?


This is impossible: they use a gradient, not just a color.


Andrei Smolin
Add-in Express Team Leader
Posted 10 Jan, 2014 09:33:40 Top