We help IT Professionals succeed at work.
Get Started

This is a .NET AddIn for a COM application. How do I get bitmap resources into toolbar buttons?

323 Views
Last Modified: 2013-11-26
Im creating an add-in using VB.NET (VS2008) for an application that has a COM interface, referenced via interops.

I have added a toolbar to the application which is functioning correctly, but I cant find a way of getting bitmaps to display on the buttons. The buttons are simply black squares!

When I created an add-in for this same application in VB6, this was not a problem. Using the resource editor, I was able to create toolbar images that resided in addin.res which was then compiled into the dll.  The images displayed correctly on the buttons.

The code in VB6 looked like this:
Object.SetAddInInfo(InstanceHandle, EnvironmentCatID, CategoryName, IDColorBitmapMedium, IDColorBitmapLarge, IDMonochromeBitmapMedium, IDMonochromeBitmapLarge, NumberOfCommands, CommandNames, CommandIDs)

ObjectRequired. The object to which the method applies.
InstanceHandleRequired Long.
EnvironmentCatIDRequired String. Specifies the ID of the environment to which the command bar button is to be added.
CategoryNameRequired String.
IDColorBitmapMediumRequired Long.
IDColorBitmapLargeRequired Long.
IDMonochromeBitmapMediumRequired Long.
IDMonochromeBitmapLargeRequired Long.
NumberOfCommandsRequired Long.
CommandNamesRequired Array of Strings.
CommandIDsRequired Array of Longs.

In VB.NET I can get the instance handle of my dll like this...
Dim aModule As System.Reflection.Module = Me.GetType().Module
Dim aModuleInstance as integer = Marshal.GetHINSTANCE(aModule).ToInt32

The difficulty I now have is trying to add a bitmap resource to my project that can then be passed to the addin via the longs in the SetAddInInfo method.

Is there any way to achieve this in .NET?
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE