Change icon of native browser node

<?xml encoding=”UTF-8″>By Adam Nagy

Changing the icon of a native browser node is similar to setting the icon of your own panel’s client node, but you work with NativeBrowserNodeDefinition and set the OverrideIcon property instead.

Sub ChangeIcon()
Dim bps As BrowserPanes
Set bps = ThisApplication.ActiveDocument.BrowserPanes
' e.g. if you want to change the root node's icon
' in the assembly "Model" panel
Dim bp As BrowserPane
Set bp = bps("AmBrowserArrangement")
Dim bmp As IPictureDisp
Set bmp = LoadPicture("C:Bitmap1.bmp")
Dim cnr As ClientNodeResource
' Only Bitmaps are supported by the Add method<br>    ' and it should be 16x16
Set cnr = bps.ClientNodeResources.Add( _
"MyResource", 2, bmp)
Dim nbnd As NativeBrowserNodeDefinition
Set nbnd = bp.TopNode.BrowserNodeDefinition
nbnd.OverrideIcon = cnr
End Sub

Comments

3 responses to “Change icon of native browser node”

  1. Thank you for providing this example however I would sure appreciate it if you could take it a step farther and show how to properly set the icon’s different states such as grounded, suppressed, etc.

  2. Hello Adam,
    could you please provide the LoadPicture Method as well (or a link where to find)?
    Thanks,
    Daniel

  3. Hi Daniel,
    That function is part of VBA. In .NET you could do e.g. this to get an IDispPicture from your loaded bitmap:
    http://adndevblog.typepad.com/manufacturing/2012/06/how-to-convert-iconbitmap-to-ipicturedisp-without-visualbasiccompatibilityvb6supporticontoipicture.html
    The SDK contains sample addins that show the whole thing: loading image, converting it to IDispPicture, adding it to a button.
    Cheers,
    Adam

Leave a Reply to dbaCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading