Hide Table of Contents
AddToolbarImage Method (IEdmCmdMgr5)

Registers an image with a toolbar button.


Visual Basic (Declaration) 
Sub AddToolbarImage( _
   ByVal lHandleOrResourceID As System.Integer, _
   ByVal lButtonCount As System.Integer, _
   ByVal eState As EdmButtonState, _
   Optional ByVal bIsIcon As System.Boolean, _
   Optional ByVal bIsHandle As System.Boolean, _
   Optional ByVal lBackgroundColorRGB As System.Integer, _
   Optional ByVal lImageID As System.Integer _
void AddToolbarImage( 
   System.int lHandleOrResourceID,
   System.int lButtonCount,
   EdmButtonState eState,
   System.bool bIsIcon,
   System.bool bIsHandle,
   System.int lBackgroundColorRGB,
   System.int lImageID
void AddToolbarImage( 
&   System.int lHandleOrResourceID,
&   System.int lButtonCount,
&   EdmButtonState eState,
&   System.bool bIsIcon,
&   System.bool bIsHandle,
&   System.int lBackgroundColorRGB,
&   System.int lImageID


Resource ID if bIsHandle = false; handle to a bitmap (bIsIcon = false) or icon (bIsIcon = true) if bIsHandle = true
Number of buttons in the bitmap or icon
State of the toolbar button (see Remarks)
True if the image is an icon; false if it is a bitmap (see Remarks)
True if lHandleOrResourceID is a handle, false if it is a resource ID
RGB value of the background color (see Remarks)
ID of the image (see Remarks)


For a more complete description of how to use this method, see Creating a menu command.

The following snippet creates a toolbar button and adds a command in the Windows Explorer Tools menu. The button uses one icon (resource ID=101) for the cold (standard) state and another one (resource ID=102) for the hot (focus) state. Both icon files must be added using Visual Basic's resource editor before running this snippet:

Private Sub IEdmAddIn5_GetAddInInfo(poInfo As EdmLib.EdmAddInInfo, ByVal poVault As EdmLib.IEdmVault5, ByVal poCmdMgr As EdmLib.IEdmCmdMgr5)

poCmdMgr.AddToolbarImage 101, 1, BState_Cold, True, False, 12632256, 1
poCmdMgr.AddToolbarImage 102, 1, BState_Hot, True, False, 12632256, 1
poCmdMgr.AddCmd 1, "My Command", EdmMenu_NeverInContextMenu Or EdmMenu_HasToolbarButton, "String to show in the statusbar", "Tooltip on my command", 0, 1

End Sub


Call this method from your add-in's implementation of IEdmAddIn5::GetAddInInfo to create a toolbar button.

Images can be either bitmaps (*.BMP) or icons (*.ICO). A bitmap contains one or more buttons of the same size. An icon contains only one button.

Unlike icons, bitmaps do not contain transparent regions. In order to get transparency in bitmaps, specify in lBackgroundColorRGB the RGB color of the bitmap that should be replaced by the background color.

When you add "hot" buttons (eState = EdmButtonState.BState_Hot), they must be assigned the same image ID as the corresponding "cold" buttons (eState = EdmButtonState.BState_Cold). Additionally, if the images contain several toolbar buttons, the buttons must be ordered the same way in both images.

Toolbar buttons in Windows Explorer can have several different sizes depending on the operating system version, Internet Explorer version, and user preferences. To make the image compatible, use this method to add several versions of an image using the same image ID but with different image sizes. SOLIDWORKS Enterprise PDM chooses the image that best matches the system settings. If the image doesn't exactly match the button size, PDM either resizes it (if the button is smaller than the image) or centers it in the button (if the button is bigger than the image).

After calling this method to create a toolbar button, call IEdmCmdMgr5::AddCmd setting lToolbarImageID to this method's lImageID.

Return codes:

  • S_OK: The method successfully executed.
  • S_FALSE: One of the arguments is invalid. 

See Also


SOLIDWORKS Enterprise PDM Version 5.2

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   AddToolbarImage Method (IEdmCmdMgr5)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.