AnsweredAssumed Answered

New Addin Icon

Question asked by Chris Champions on Feb 18, 2016
Latest reply on Feb 19, 2016 by Sdiri Marwa

I tried to modify the sub from the Addin Template - see the code below

it's working fine with 3 items shown on the drop-down menu, however, only 2 icons are shown on the FM - what I'm missing here

Any help, please







Public Sub AddCommandMgr()



        Dim cmdGroup As ICommandGroup



        If iBmp Is Nothing Then

            iBmp = New BitmapHandler()

        End If



        Dim thisAssembly As Assembly



        Dim cmdIndex0 As Integer, cmdIndex1 As Integer, cmdIndex2 As Integer 'Add new cmdIndex2

        Dim Title As String = "VB Addin1"

        Dim ToolTip As String = "VB Addin1"





        Dim docTypes() As Integer = {swDocumentTypes_e.swDocASSEMBLY, _

                                       swDocumentTypes_e.swDocDRAWING, _




        thisAssembly = System.Reflection.Assembly.GetAssembly(Me.GetType())



        Dim cmdGroupErr As Integer = 0

        Dim ignorePrevious As Boolean = False



        Dim registryIDs As Object = Nothing

        Dim getDataResult As Boolean = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, registryIDs)



        Dim knownIDs As Integer() = New Integer(2) {mainItemID1, mainItemID2, mainItemID3}



        If getDataResult Then

            If Not CompareIDs(registryIDs, knownIDs) Then 'if the IDs don't match, reset the commandGroup

                ignorePrevious = True

            End If

        End If



        cmdGroup = iCmdMgr.CreateCommandGroup2(mainCmdGroupID, Title, ToolTip, "", -1, ignorePrevious, cmdGroupErr)

        If cmdGroup Is Nothing Or thisAssembly Is Nothing Then

            Throw New NullReferenceException()

        End If







        cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap("Test1.ToolbarLarge.bmp", thisAssembly)

        cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap("Test1.ToolbarSmall.bmp", thisAssembly)

        cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap("Test1.MainIconLarge.bmp", thisAssembly)

        cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap("Test1.MainIconSmall.bmp", thisAssembly)



        Dim menuToolbarOption As Integer = swCommandItemType_e.swMenuItem Or swCommandItemType_e.swToolbarItem



        cmdIndex0 = cmdGroup.AddCommandItem2("CreateCube", -1, "Create a cube", "Create cube", 0, "CreateCube", "", mainItemID1, menuToolbarOption)

        cmdIndex1 = cmdGroup.AddCommandItem2("Show PMP", -1, "Display sample property manager", "Show PMP", 2, "ShowPMP", "PMPEnable", mainItemID2, menuToolbarOption)

        cmdIndex2 = cmdGroup.AddCommandItem2("NewItemName", -1, "NewItemHintString", "ToolTip", 0, "NewItemCallBackFunction", "", mainItemID3, menuToolbarOption)









        cmdGroup.HasToolbar = True

        cmdGroup.HasMenu = True




        Dim flyGroup As FlyoutGroup

        flyGroup = iCmdMgr.CreateFlyoutGroup(flyoutGroupID, "Dynamic Flyout", "Flyout Tooltip", "Flyout Hint", _

              cmdGroup.SmallMainIcon, cmdGroup.LargeMainIcon, cmdGroup.SmallIconList, cmdGroup.LargeIconList, "FlyoutCallback", "FlyoutEnable")



        flyGroup.AddCommandItem("FlyoutCommand 1", "test", 0, "FlyoutCommandItem1", "FlyoutEnableCommandItem1")



        flyGroup.FlyoutType = swCommandFlyoutStyle_e.swCommandFlyoutStyle_Simple





        For Each docType As Integer In docTypes

            Dim cmdTab As ICommandTab = iCmdMgr.GetCommandTab(docType, Title)

            Dim bResult As Boolean



            If Not cmdTab Is Nothing And Not getDataResult Or ignorePrevious Then 'if tab exists, but we have ignored the registry info, re-create the tab.  Otherwise the ids won't matchup and the tab will be blank

                Dim res As Boolean = iCmdMgr.RemoveCommandTab(cmdTab)

                cmdTab = Nothing

            End If



            If cmdTab Is Nothing Then

                cmdTab = iCmdMgr.AddCommandTab(docType, Title)



                Dim cmdBox As CommandTabBox = cmdTab.AddCommandTabBox



                Dim cmdIDs(3) As Integer

                Dim TextType(3) As Integer



                cmdIDs(0) = cmdGroup.CommandID(cmdIndex0)

                TextType(0) = swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal



                cmdIDs(1) = cmdGroup.CommandID(cmdIndex1)

                TextType(1) = swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal



                cmdIDs(2) = cmdGroup.ToolbarId

                TextType(2) = swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal





                bResult = cmdBox.AddCommands(cmdIDs, TextType)



                Dim cmdBox1 As CommandTabBox = cmdTab.AddCommandTabBox()

                ReDim cmdIDs(1)

                ReDim TextType(1)



                cmdIDs(0) = flyGroup.CmdID

                TextType(0) = swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow



                bResult = cmdBox1.AddCommands(cmdIDs, TextType)



                cmdTab.AddSeparator(cmdBox1, cmdIDs(0))



            End If




        thisAssembly = Nothing



    End Sub