troubleshooting Question

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

Avatar of DavidRothan
DavidRothanFlag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution325 ViewsLast Modified:
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?

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros