ArcObjects Library Reference (Framework)  

ICommandItem.FaceID Property

The bitmap that is used as the icon on this command item.

[Visual Basic .NET]
Public Property FaceID As Object
[C#]
public object FaceID {get; set;}

Product Availability

Available with ArcGIS Desktop.

Description

The values for FaceID from the built-in icon palette are:

You can also use your own bitmap (.bmp file) with ICommandItem::FaceID. To use your own bitmap, you could create a UserForm in VBA with a Image control on it. Set the Picture property of the Image control to your bitmap.

If you are using your own bitmap, it must be a Bitmap file (.bmp); Icon files (.ico) are not supported. Bitmap files should be 16 X 16 pixels. The color of the upper left pixel of the bitmap is treated as the transparent color. For example, if the upper left pixel of the bitmap is red, then all of the red pixels in the bitmap will be converted to transparent.

[C#]

The following example shows how to change the icon on the ArcMap What's This Help tool on the Standard toolbar. FaceID is set to a bitmap named "newIcon.bmp" compiled as embedded resource in the assembly.

public void ChangeIcon(IDocument document)
{
    ICommandBars documentBars = document.CommandBars;
    UID barID = new UIDClass();
    barID.Value = "{5DEB1DB8-C2A9-11D1-B9A2-080009EE4E51}";
    ICommandItem standardBarItem = documentBars.Find(barID, false, false);
    //If toolbar is found and is a type of ICommandBar
    if (standardBarItem != null && standardBarItem is ICommandBar)
    {
        ICommandBar standardToolbar = (ICommandBar)standardBarItem;
        UID commandID = new UIDClass();
        commandID.Value = "{81972F0D-388A-11D3-9F57-00C04F6BC61A}";
        ICommandItem contextHelpItem = standardToolbar.Find(commandID, false);
        if (contextHelpItem != null)
        {
            //Get a bitmap first. Here is the embedded resource in the assembly
            System.Drawing.Bitmap newIcon = new System.Drawing.Bitmap(GetType(), "newIcon.bmp");
            contextHelpItem.FaceID = ESRI.ArcGIS.Utility.COMSupport.OLE.GetIPictureDispFromBitmap(newIcon);
        }
    }
}
[Visual Basic .NET]

The following example shows how to change the icon on the ArcMap What's This Help tool on the Standard toolbar. FaceID is set to a bitmap named "newIcon.bmp" compiled as embedded resource in the assembly.

Sub ChangeIcon(document As IDocument)
    Dim documentBars As ICommandBars = document.CommandBars
    Dim barID As UID = new UIDClass
    barID.Value = "{5DEB1DB8-C2A9-11D1-B9A2-080009EE4E51}"
    Dim standardBarItem As ICommandItem = documentBars.Find(barID)
    ' If toolbar is found and is a type of ICommandBar
    If Not standardBarItem Is Nothing Then 
        If Typeof standardBarItem Is ICommandBar Then
           Dim standardToolbar As ICommandBar = CType(standardBarItem, ICommandBar)
           Dim commandID As UID = New UIDClass()
           commandID.Value = "{81972F0D-388A-11D3-9F57-00C04F6BC61A}"
           Dim contextHelpItem As ICommandItem = standardToolbar.Find(commandID)
           If Not contextHelpItemIs Nothing Then
               'Get a bitmap first. Here is the embedded resource in the assembly
               Dim newIcon As System.Drawing.Bitmap = New System.Drawing.Bitmap(Me.GetType(), "newIcon.bmp")
               contextHelpItem.FaceID = ESRI.ArcGIS.Utility.COMSupport.OLE.GetIPictureDispFromBitmap(newIcon)
           End If
       End If
   End If
End Sub

See Also

ICommandItem Interface