AnsweredAssumed Answered

How to delete default tab in addin template?

Question asked by Vlad Honcharenko on Jun 21, 2016
Latest reply on Jun 22, 2016 by Viktor Bovzdarenko

Hi! I have created add-in from C# template for SW, and added custom tab(Custom Title), but now I can't delete standard tab(C# Add In), how to do that?

 

a.png

Some Code:

public void AddCommandMgr()

        {    ICommandGroup cmdGroup;

            if (iBmp == null)

                iBmp = new BitmapHandler();

            Assembly thisAssembly;

            int cmdIndex1, cmdIndex2;

            string Title = "Custom Title", ToolTip = "Custom ToolTip";

            int[] docTypes = new int[]{(int)swDocumentTypes_e.swDocASSEMBLY,

                                       (int)swDocumentTypes_e.swDocDRAWING,

                                       (int)swDocumentTypes_e.swDocPART,

                                       (int)swDocumentTypes_e.swDocNONE};

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());

            int cmdGroupErr = 0;

            bool ignorePrevious = false;

            object registryIDs;

            //get the ID information stored in the registry

            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(mainCmdGroupID, out registryIDs);

           int[] knownIDs = new int[3] { mainItemID1, mainItemID2, mainItemID3 };

            if (getDataResult)

            {

                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup

                {

                    ignorePrevious = true;

                }

            }

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

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

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

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

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

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);

 

            cmdIndex1 = cmdGroup.AddCommandItem2("Menu Item 1", -1, "Menu Item 1", "Menu Item 1", 0, "Something1", "", mainItemID1, menuToolbarOption);

            cmdIndex2 = cmdGroup.AddCommandItem2("Menu Item 2", -1, "Menu Item 2", "Menu Item 2", 1, "Something2", "", mainItemID2, menuToolbarOption);

           cmdGroup.HasToolbar = true;

            cmdGroup.HasMenu = false;

            cmdGroup.Activate();

            bool bResult;

            foreach (int type in docTypes)

            {

                if (type == 1)

                {

                    CommandTab cmdTab1;

                    cmdTab1 = iCmdMgr.GetCommandTab(type, Title);

                    if (cmdTab1 != null & !getDataResult | ignorePrevious)

                    {

                        bool res = iCmdMgr.RemoveCommandTab(cmdTab1);

                        cmdTab1 = null;

                    }

                    if (cmdTab1 == null)

                    {

                        cmdTab1 = iCmdMgr.AddCommandTab(type, Title);

                        CommandTabBox cmdBox = cmdTab1.AddCommandTabBox();

                        int[] cmdIDs1 = new int[3];

                        int[] TextType1 = new int[3];

                        cmdIDs1[0] = cmdGroup.get_CommandID(cmdIndex1);

                        TextType1[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;

                        cmdIDs1[1] = cmdGroup.get_CommandID(cmdIndex2);

                        TextType1[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;

                        bResult = cmdBox.AddCommands(cmdIDs1, TextType1);

                    }

                }                         

            }

            thisAssembly = null;

            iBmp.Dispose();

        }

Outcomes