Need Help on CommandManager & commandGroup

121 views
Skip to first unread message
Message has been deleted

sandeep

unread,
Mar 5, 2009, 12:14:23 AM3/5/09
to SolidWorks-API
Hi,
I am new to SolidWorks API programming. What I am trying to achieve is
putting command group (toolbar) on command manager tab. I succeeded to
add it on commandmanager tab. But when none of the methods in the
toolbar are enabled still the commandgroup tab is enabled. How to
disable it? My code is like:

private void AddCommandMgr()
{
ICommandGroup cmdGroup;
BitmapHandler iBmp = new BitmapHandler();
Assembly thisAssembly;

string Title = "TestCmdMgr";
string ToolTip = "TestCmdMgr";

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

cmdGroup = iCmdMgr.CreateCommandGroup(1, Title, ToolTip,
"", -1);
cmdGroup.LargeIconList = iBmp.CreateFileFromResourceBitmap
("PlugInObjectInfo.Resources.ToolbarLarge.bmp", thisAssembly);
cmdGroup.SmallIconList = iBmp.CreateFileFromResourceBitmap
("PlugInObjectInfo.Resources.ToolbarSmall.bmp", thisAssembly);
cmdGroup.LargeMainIcon = iBmp.CreateFileFromResourceBitmap
("PlugInObjectInfo.Resources.MainIconLarge.bmp", thisAssembly);
cmdGroup.SmallMainIcon = iBmp.CreateFileFromResourceBitmap
("PlugInObjectInfo.Resources.MainIconSmall.bmp", thisAssembly);

int cmdIndex0 = cmdGroup.AddCommandItem2("Test 0", -1,
"Test0", "Test0", 0, "TestMgr", "EnableMgr", 0, (int)
SwConst.swCommandItemType_e.swMenuItem);
int cmdIndex1 = cmdGroup.AddCommandItem2("Test 1", -1,
"Test1", "Test1", 1, "TestMgr", "EnableMgr", 1, (int)
SwConst.swCommandItemType_e.swMenuItem);
int cmdIndex2 = cmdGroup.AddCommandItem2("Test 2", -1,
"Test2", "Test2", 2, "TestMgr", "EnableMgr", 2, (int)
SwConst.swCommandItemType_e.swMenuItem);

cmdGroup.HasToolbar = true;
cmdGroup.HasMenu = false;

cmdGroup.Activate();
int docType = (int)SwConst.swDocumentTypes_e.swDocPART;

CommandTab cmdTab = iCmdMgr.GetCommandTab(docType, Title);

if (cmdTab == null)
{
cmdTab = iCmdMgr.AddCommandTab(docType, Title);

CommandTabBox cmdBox = cmdTab.AddCommandTabBox();
if (cmdBox == null)
{
cmdTab = iCmdMgr.AddCommandTab(docType, Title);
if (cmdTab == null)
return;
cmdBox = cmdTab.AddCommandTabBox();
if (cmdBox == null)
return;
}

int[] cmdId = new int[1];
int[] textType = new int[1];

cmdId[0] = cmdGroup.ToolbarId;
textType[0] = (int)
SwConst.swCommandTabButtonTextDisplay_e.swCommandTabButton_TextHorizontal;

cmdBox.AddCommands(cmdId, textType);
}
thisAssembly = null;
iBmp.Dispose();
}

public void TestMgr()
{
MessageBox.Show("This is a test");
}
public int EnableMgr()
{
return 0;
}
Reply all
Reply to author
Forward
0 new messages