views:

173

answers:

1

I am developing a COM Add-in using VB.NET in Visual Studio 2008 Pro for Outlook 2003 and am having trouble assigning images to custom toolbar buttons.

In a nutshell, I am having to convert from an Icon type to a stdole.IPictureDisp type so that I can assign my buttons a picture.

The picture displays, but it loses the Alpha channel and the background is no longer transparent. I can verify that before the conversion to IPictureDisp object, that the PixelFormat property is set to Format32bppArgb (2498570). I am using a coding technique suggested here: http://msdn.microsoft.com/en-us/library/ms268747%28VS.80%29.aspx.

For C# users, this link blogs.msdn.com/andreww/archive/2007/10/10/preserving-the-alpha-channel-when-converting-images.aspx (sorry I am newbie and can't post more than one link! Dumb rule BTW) shows how to modify the IPictureDisp one pixel at a time and rebuild the transparency, but I can't find similar functions in VB.NET...

I would appreciate any advice regarding this. Thanks.

A: 

If you read to end of the article the author notes in one of the comments that the command bars API doesnt support alpha channels on images. You can of course cheat a little, if you draw your image onto a bitmap that matches the background of the toolbar and assign that composite image to the toolbar button, you would have a toolbar image that "looks" transparent.

Joe Caffeine
@Joe Thanks for replying... Yes, I saw that, but I also know that there must be a way (maybe not in VB.NET) to do it since other add-ins have transparent buttons. Do you have any ideas in VB for manipulating pixels within an IPictureDisp object?
Scott Lundberg
Why not take the c# sample and put it in a library you can reference from vb.net?
Joe Caffeine