admin管理员组文章数量:1023213
Having a code which is not working, and cannot get why from SW API documentation.
Trying to add a context menu to a part. Not showing, no matter what I do! ( Also not able to find a callback function, when its clicked (when ill get it).
internal static SldWorks SwApp;
internal static int cookie;
public bool ConnectToSW(object ThisSW, int Cookie)
{
SwApp = (SldWorks)ThisSW;
cookie = Cookie;
ICommandManager icmd = SwApp.GetCommandManager(cookie);
ICommandGroup cmdGroup;
var a = icmd.AddContextMenu(1, "Test");
a.SelectType = (int)swSelectType_e.swSelEVERYTHING; //tried other options too
a.AddCommandItem2("Test2", -1, "hint", "tool tip", 1, "Booom", "", 1, (int)(swCommandItemType_e.swMenuItem));
a.ShowInDocumentType = (int)swDocumentTypes_e.swDocPART;
a.HasMenu = true;
//a.Activate(); //cannot be set on contextmenu object. only on CommandGroup.
//cmdGroup.AddCommandGroup2(); // working. Im able to add both menu and toolbar (but not contextmenu)
return true;
}
thanks a lot!
Having a code which is not working, and cannot get why from SW API documentation.
Trying to add a context menu to a part. Not showing, no matter what I do! ( Also not able to find a callback function, when its clicked (when ill get it).
internal static SldWorks SwApp;
internal static int cookie;
public bool ConnectToSW(object ThisSW, int Cookie)
{
SwApp = (SldWorks)ThisSW;
cookie = Cookie;
ICommandManager icmd = SwApp.GetCommandManager(cookie);
ICommandGroup cmdGroup;
var a = icmd.AddContextMenu(1, "Test");
a.SelectType = (int)swSelectType_e.swSelEVERYTHING; //tried other options too
a.AddCommandItem2("Test2", -1, "hint", "tool tip", 1, "Booom", "", 1, (int)(swCommandItemType_e.swMenuItem));
a.ShowInDocumentType = (int)swDocumentTypes_e.swDocPART;
a.HasMenu = true;
//a.Activate(); //cannot be set on contextmenu object. only on CommandGroup.
//cmdGroup.AddCommandGroup2(); // working. Im able to add both menu and toolbar (but not contextmenu)
return true;
}
thanks a lot!
本文标签: menuSolidworks API AddContextMenu CStack Overflow
版权声明:本文标题:menu - Solidworks API AddContextMenu C# - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745588101a2157721.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论