Tweaking images in Face list

S

seacuke

I've got an email add-in that has to be compatible with Outlook 2000 as
well as XP & 2003. The add-in's UI is a button placed on the standard
toolbar.

We would like to have a customized icon on the button, but have run
into an issue with the masking of the icon when the button is disabled;
I've worked with a lot of tweaks and toys trying to get the icon to
have a mask.

I'm writing in C#, and have tried to translate the VB code in this
article: http://support.microsoft.com/default.aspx?scid=kb;en-us;288771
to something I could use, and have had zero luck.

I noticed from trial and experimentation that the Office default
toolbar icons all mask very nicely (how convenient), and was wondering
if there was a way to get into that set of bitmaps and alter them so
that we could fake it into masking our icon?

Or, if anyone knows of a solution in C# that effectively creates a
bitmap that is masked properly when applied to a commandbarbutton it
would be a great help to me.

Here's the code that we're using to generate the icon:

// Load the existing image (blank) into the clipboard,
// so that we get the color of their default background.
syncButton.CopyFace();
IDataObject maskObject = Clipboard.GetDataObject();

maskBitmap = (Bitmap)maskObject.GetData(typeof (Bitmap));

// Load our image
Bitmap treeBitmap =
(Bitmap)Bitmap.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("addIn.SyncButtonImage.bmp"));

// Create new Graphics object based on the 'empty'
// bitmap loaded from the button.
Graphics graphics = Graphics.FromImage(maskBitmap);

// Mask our magenta
treeBitmap.MakeTransparent(Color.FromArgb(255,0,255));

// Apply our icon to the 'empty' bitmap
graphics.DrawImage(treeBitmap,0,0);

// Load bitmap and stash it on the button face.
Clipboard.SetDataObject(maskBitmap);
syncButton.PasteFace();
 
K

Ken Slovak - [MVP - Outlook]

One alternative, which you might want to consider, is to use late binding
code to call the Picture and Mask properties if the user is running Outlook
2002 or later and just put up an unmasked button for Outlook 2000. Since
Outlook 2000 doesn't support Windows XP theming it might be an acceptable
solution.

FWIW, I see problems at random times even with VB 6 code that uses code
similar to that KB article where the magenta mask shows up instead of the
transparent masked background. Most times it works but sometimes for no
apparent reason you get that mask showing up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top