Welcome to MSDN Blogs Sign in | Join | Help

Displaying custom bitmap for VS add-in command button from satellite DLL

Add-ins can get resources such as strings, icons, and bitmaps from satellite DLLs which separates resources from your add-in. The first time I tried to get add-in resources from its satellite DLL, I easily find out how to do it for resources like strings and icons. But for bitmaps, it took me really a long time to figure out (for both native & managed add-ins). There indeed are some tricky steps that are hard to find out, so I thought it would be really good to blog it.

In previous verions of VS (2002 & 2003), add-ins used reg key values "SatelliteDllName" and "SatelliteDllPath" to store info for satellite DLLs. Now with Visual Studio 2005, you don't need to bother with registry for managed add-ins (although you still need it for native add-ins) any more. For resources like strings and icons, it is quite straightforward. To briefly state here, you simply prepend the resource name with the @ character in the .Addin XML file, in this way the add-in will look for the resource from its satellite DLL, e.g. <FriendlyName>@String1</FriendlyName>. "String1" is the resource name in the satellite DLL. One thing I want to point out is, for add-in Help/About box icon, you need to use tag <AboutIconLocation> instead of <AboutIconData>, like <AboutIconLocation>@Icon1</AboutIconLocation>, which may be confusing.

For resources like bitmaps, the way you get it from satellite DLLs is quite different and tricky. From my experience, It seems like if you miss one little step, you won't get it work and it is hard to figure out what's going wrong. What's more, the way you do it for native add-ins and managed add-ins is different. So I am going to list the steps in detail here for both native & managed add-ins respectively:

Creating a native satellite DLL with a custom bitmap and getting it from a native add-in:

    1. Create a C++ Win32 DLL
    2. Add a Resource File (.rc)
    3. In Resource View, add a bitmap (16 x 16), give it a numeric ID
    4. Build the DLL
    5. Create a subfolder "1033" (for English locale) in the native add-in DLL directory
    6. Copy the satellite DLL to "1033" directory

To get the bitmap show up with the command, make sure
    1. The bitmap must be 16 x 16 (True Color)
    2. Update AddNamedCommand2 in Connect.cpp with 'MSOButton' set to VARIANT_FALSE, and 'Bitmap' set to the bitmap ID
    3. Open AddIn.rgs and add two reg key values "SatelliteDllName" and "SatelliteDllPath" (see the example below)
    4. Rebuild the add-in to get the updated info registered

(NOTE: One thing you may miss here in 3. is: for "SatelliteDllPath" do not put the locale ID although it is part of the full path, it will be automatically appended at runtime)

Here is an example:

HKCU
{
 NoRemove 'SOFTWARE'
 {
  NoRemove 'Microsoft'
  {
   NoRemove 'VisualStudio'
   {
    NoRemove '8.0'
    {
     NoRemove 'AddIns'
     {
      ForceRemove 'NativeAddinCustBitmap.Connect'
      {
       val LoadBehavior = d 0
       val CommandLineSafe = d 0
       val CommandPreload = d 1
       val FriendlyName = s 'NativeAddinCustBitmap'
       val Description = s 'NativeAddinCustBitmap Description'
       val SatelliteDllName = s 'NativeAddinCustBitmapUI.dll'
       val SatelliteDllPath = s 'E:\CustomBitmap\NativeAddinCustBitmap\NativeAddinCustBitmap\Debug'
      }
     }
    }
   }
  }
 }
}

Creating a managed satellite DLL with a custom bitmap and getting it from a managed add-in:

    1. Add a Resources file to the managed add-in project, say "Resource1.resx" (set the Build Action to None)
    2. Add your bitmap (16 x 16) to the resource, give the bitmap a numeric ID
    3. Run "resgen Resource1.resx" to create "Resource1.resources"
    4. Run "al.exe /embed:Resource1.resources /culture:en-US /out:YourAddinName.resources.dll
    (use System.Globalization.CultureInfo.InstalledUICulture to get the correct culture, here I use 'en-US' as an example.)
    5. Create a subfolder named 'en-US' or the correct culture name in the add-in DLL directory
    6. Copy YourAddinName.resources.dll to the subfolder created in step 5.
       (One handy thing is that you don't even need to put satelliteDll info in the .AddIn XML file.)

To get the bitmap show up with the command, make sure:
    1. The bitmap must be 16 x 16 (True Color or 16 Color)
    2. The bitmap must have a name that is actually decimal number. The ResX designer in VS doesn't allow numeric IDs for resources. You have to edit the resx directly and ignore the warnings.
    3. Update AddNamedCommand2 with 'MSOButton' param set to false, and the 'bitmap' param set to the bitmap ID.

Hope I have made it clear.

Published Tuesday, September 27, 2005 7:53 PM by hlong

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Thanks, Good writing.
I like the new loading process of managed add-ins.
The schema for the AutomationExtensibility still has no entry for the AboutIconLocation node. That's a little bit confusing. Can it be fixed for the final version ?
(C:\Programme\Microsoft Visual Studio 8\Xml\Schemas\addinschema.xsd)
Friday, September 30, 2005 11:50 AM by MatHertel

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Thanks Mat for the comment!
You are right. The schema does miss the entry for AboutIconLocation, but unfortunately the fix can not get into the final build cause it does not meet the product bar and we already kind of locked down.
Friday, September 30, 2005 5:38 PM by hlong

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

So how does this AbuotIconLocation key work? What needs to go in there specifically? I've tried both bitmap and icon resources from a managed resource DLL and it's just showing blank. I also tried embedding the binary data - doesn't work either. I suspect there's some issue with the image. Any special resolution?
Monday, October 31, 2005 6:00 AM by Rick Strahl

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

It would be good to remove this complexity forever. See:

Suggestion Details: Custom pictures for commands using icons without satellite DLLs

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=95e70321-3f0c-4273-9895-89a6f11dd0c3

Tuesday, November 29, 2005 12:23 PM by Carlos Quintero (MVP)

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Hello Rick,

I don't know how AboutIconLocation works, but you can embed icon data in the AboutIconData eleemnt using this little command-line program to convert the icon data to text.

Frank Hileman

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace IconExtractor
{
class Program
{
static void Main(string[] args)
{
string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.ico");
foreach (string file in files)
{
Console.WriteLine(file);
string textName = Path.ChangeExtension(file, ".txt");
using (StreamWriter sw = new StreamWriter(textName))
{
byte[] data = File.ReadAllBytes(file);
for (int i = 0; i < data.Length; i++)
sw.Write(data[i].ToString("X2"));
sw.Close();
}
}
}
}
}
Sunday, December 11, 2005 12:36 PM by Frank Hileman

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

http://rw.da.cx  <a href="http://rw.da.cx">replica watches</a> replica watches

Monday, January 08, 2007 7:44 AM by replica watches

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

luogo interessante, soddisfare interessante, buon!

Monday, March 05, 2007 4:44 AM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Luogo molto buon:) Buona fortuna!

Saturday, March 10, 2007 4:28 PM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

E evidente che il luogo e stato fatto dalla persona che realmente conosce il mestiere!

Tuesday, March 13, 2007 7:09 AM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

luogo interessante, soddisfare interessante, buon!

Thursday, March 15, 2007 5:06 PM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Lo trovo piuttosto impressionante. Lavoro grande fatto..)

Saturday, March 17, 2007 11:37 AM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Stupore! ho una sensibilit molto buona circa il vostro luogo!!!!

Monday, March 19, 2007 2:44 AM by ...

# [导入]收集了一些关于VS 2005 Add-in开发的文章

Explorer-AVisualStudio2005add-inwhichinteractswithWindowsExplorerHowtodebugaVisualS...

Thursday, March 22, 2007 5:59 AM by

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

pagine piuttosto informative, piacevoli =)

Wednesday, April 11, 2007 2:32 AM by ...

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

Stupore! ho una sensibilit molto buona circa il vostro luogo!!!!

Saturday, April 14, 2007 10:31 PM by ...

# star tattoo

The star has numerous meanings depending on who is wearing it. For some it may signify honesty. For others it is a symbol of hope and beauty. Star tattoo ideas from person to person. The number of points the star contain is the most meaningful way to personalize it. A particular color of the star is also a very great way to personalize your star tattoo. While the most common types of stars are the 4 pointed and 5 pointed stars, other star tattoo ideas are out there if you look hard enough.

http://xcrssabg.007webpro.com/star-tattoo.htm

Thursday, May 17, 2007 12:23 PM by star tattoo

# oscardelahoyapayperview

<a href="httpwwwnzgsravqcnpage11html">ebonydoesivorycompilationguydasilva</a> ebonydoesivorycompilationguydasilva,<a href="httpwwwnzgsravqcnpage21html">villagersrampagedbyvladuzphisherebayimpaling</a> villagersrampagedbyvladuzphisherebayimpaling,<a href="httpwwwnzgsravqcnpage17html">netflixdvdmoviesblockbuster</a> netflixdvdmoviesblockbuster,<a href="httpwwwnzgsravqcnpage13html">mayweatherdelahoyabaltimorebars</a> mayweatherdelahoyabaltimorebars,<a href="httpwwwnzgsravqcnpage30html">completenarutosoundtrack</a> completenarutosoundtrack,<a href="httpwwwnzgsravqcnpage27html">coprintingscotland</a> coprintingscotland,<a href="httpwwwnzgsravqcnpage32html">wwwchedgovph</a> wwwchedgovph,<a href="httpwwwnzgsravqcnpage38html">latewwiijapaneseaircraft</a> latewwiijapaneseaircraft,<a href="httpwwwnzgsravqcnpage12html">walmartturkeyner</a> walmartturkeyner,<a href="httpwwwnzgsravqcnpage10html">usedexerciseequipmentbowflexhomegymda038</a> usedexerciseequipmentbowflexhomegymda038,

Wednesday, August 01, 2007 12:11 AM by oscardelahoyapayperview

# subaruliberty

<a href="httpwwwkiklbjvgcnpage46html">spanishleters</a> spanishleters,<a href="httpwwwkiklbjvgcnpage29html">immigrationbiometricsworkpermit</a> immigrationbiometricsworkpermit,<a href="httpwwwkiklbjvgcnpage22html">airbusboeingcompetition</a> airbusboeingcompetition,<a href="httpwwwkiklbjvgcnpage35html">hennepincountypropertytaxeshomeowners</a> hennepincountypropertytaxeshomeowners,<a href="httpwwwkiklbjvgcnpage25html">subarucd</a> subarucd,<a href="httpwwwkiklbjvgcnpage28html">adultswingersintimberlakesouthdakota</a> adultswingersintimberlakesouthdakota,<a href="httpwwwkiklbjvgcnpage36html">kidsflyfreechicago</a> kidsflyfreechicago,<a href="httpwwwkiklbjvgcnpage41html">subaruimprezabonnet</a> subaruimprezabonnet,<a href="httpwwwkiklbjvgcnpage47html">newjerseyclaimsadjuster</a> newjerseyclaimsadjuster,<a href="httpwwwkiklbjvgcnpage25html">subaruimpreza15tuningmodify</a> subaruimpreza15tuningmodify,

Wednesday, August 01, 2007 8:34 AM by subaruliberty

# porsche911grandprixwhite

<a href="httpwwwdhcgpdiacnpage64html">messagequeuevb6</a> messagequeuevb6,<a href="httpwwwdhcgpdiacnpage56html">eg</a> eg,<a href="httpwwwdhcgpdiacnpage42html">sometimesifeellikethrowingmyhandsup</a> sometimesifeellikethrowingmyhandsup,<a href="httpwwwdhcgpdiacnpage66html">fentoncranberryglass</a> fentoncranberryglass,<a href="httpwwwdhcgpdiacnpage45html">australianwomenwarcorrespondentsworldwar2</a> australianwomenwarcorrespondentsworldwar2,<a href="httpwwwdhcgpdiacnpage40html">bangbrosip</a> bangbrosip,<a href="httpwwwdhcgpdiacnpage61html">craigpricematures</a> craigpricematures,<a href="httpwwwdhcgpdiacnpage41html">resultsofpeoplehavingcandidayeasttreated</a> resultsofpeoplehavingcandidayeasttreated,<a href="httpwwwdhcgpdiacnpage63html">redcheckeredtableclothclipart</a> redcheckeredtableclothclipart,<a href="httpwwwdhcgpdiacnpage68html">porsche964641536</a> porsche964641536,

Wednesday, August 01, 2007 9:16 AM by porsche911grandprixwhite

# chiendebrittany224

<a href="httpwwwrrsanfhtcnpage74html">vitaminsadc-fluoride-irondrops</a> vitaminsadc-fluoride-irondrops,<a href="httpwwwrrsanfhtcnpage69html">brittanyrodgers-myspace</a> brittanyrodgers-myspace,<a href="httpwwwrrsanfhtcnpage75html">cowboyridingapig</a> cowboyridingapig,<a href="httpwwwrrsanfhtcnpage76html">sbc327enginebuildup</a> sbc327enginebuildup,<a href="httpwwwrrsanfhtcnpage66html">mortalkombatdeceptionunlockcharacters</a> mortalkombatdeceptionunlockcharacters,<a href="httpwwwrrsanfhtcnpage78html">designsforstandupdesks</a> designsforstandupdesks,<a href="httpwwwrrsanfhtcnpage63html">threewishescompany</a> threewishescompany,<a href="httpwwwrrsanfhtcnpage70html">freemedicalcfnm</a> freemedicalcfnm,<a href="httpwwwrrsanfhtcnpage65html">orlandofreebies</a> orlandofreebies,<a href="httpwwwrrsanfhtcnpage70html">newcfnm</a> newcfnm,

Wednesday, August 01, 2007 1:15 PM by chiendebrittany224

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

How do these resource DLL's get deployed ?  If I try and create a VS2005 Setup and Deployment project for my add-in with managed resource, I get an "Unable to find file '<addinName>.dll' of multi-file assembly '<addinName>.resources.dll'.

Surely MS haven't given us the capability to create the addin without a tool to deploy it ?

Tuesday, June 03, 2008 12:42 PM by Stack

# Visual Studio 2005/2008 managed add-ins using XML registration (.AddIn file) and unmanaged satellite DLLs

In my last entry I mentioned that I was investigating to use XML registration (.AddIn File) with my MZ

Wednesday, October 01, 2008 4:08 AM by Carlos Quintero (Microsoft MVP) blog

# supervixens movie

supervixens movie [URL=http://lakinkea.strefa.pl/comment-298.htm]supervixens movie[/URL] [url=http://lakinkea.strefa.pl/comment-298.htm]supervixens movie[/url] [url]http://lakinkea.strefa.pl/comment-298.htm[/url]

Wednesday, December 10, 2008 9:49 PM by supervixens movie

# re: Displaying custom bitmap for VS add-in command button from satellite DLL

話題の小向美奈子ストリップを隠し撮り!入念なボディチェックをすり抜けて超小型カメラで撮影した神動画がアップ中!期間限定配信の衝撃的映像を見逃すな

Saturday, June 13, 2009 12:05 PM by 小向美奈子

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker