johnson
johnson

Reputation: 35

Add VS icon pack to VS plugin, visual studio plug-ins development

I'm creating an add-in for VS, how to add icon getting from VS icon pack for the menu command button?

Getting icon from resource code example

<GuidSymbol name="testIcon" value="{00000000-0000-0000-0000-0000}">  
    <IDSymbol name="testIcon1" value="1" />  
</GuidSymbol> 
<Bitmap guid="testIcon" href="Resources\Icon.png" usedList="testIcon1"/>
<Button guid="guidAddIconCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">  
    <Parent guid="guidAddIconCmdSet" id="MyMenuGroup" />  
    <Icon guid="testIcon" id="testIcon1" />  
    <Strings>  
        <ButtonText>My Command name</ButtonText>  
    </Strings>  
</Button>

Upvotes: 1

Views: 317

Answers (1)

Khoa Nguyen
Khoa Nguyen

Reputation: 103

Known Monikers - The set of image monikers contained in the Visual Studio Image Catalog and publicly consumable by any Visual Studio component or extension. This one is a good choice, let's try.

  • Firstly, include this library KnownImageIds.vsct in you .vsct file
  • Modify the code to add what icon you need around <Icon> tag
  • Add flag <CommandFlag>IconIsMoniker</CommandFlag>

For example, add VS "open folder" icon to your menu command

<Include href="KnownImageIds.vsct"/>
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<GuidSymbol name="testIcon" value="{00000000-0000-0000-0000-0000}">  
    <IDSymbol name="testIcon1" value="1" />  
</GuidSymbol> 
<Bitmap guid="testIcon" href="Resources\Icon.png" usedList="testIcon1"/>
<Button guid="guidAddIconCmdSet" id="cmdidMyCommand" priority="0x0100" type="Button">  
    <Parent guid="guidAddIconCmdSet" id="MyMenuGroup" />  
    <Icon guid="ImageCatalogGuid" id="OpenFolder" /> // icon id
    <CommandFlag>IconIsMoniker</CommandFlag>         // enable moniker
    <Strings>  
        <ButtonText>My Command name</ButtonText>  
    </Strings>  
</Button>

Upvotes: 1

Related Questions