NX二次开发treelist控件添加右键快捷菜单回调函数的简单例子
<p><div class="blockcode"><blockquote>enum MenuID
{
RemovetopNode = 0,
DeleteNode,
CheckedMenuItem,
DefaultMenuItem,
DialogLaunchMenuItem,
DisableMenuItem,
HiddenMenuItem,
IconMenuItem,
SubMenuItem1,
SubMenuItem2,
SubMenuItem3,
SubMenuItem4,
historymenu,
nohistorymenu,
modelhistoryfilter,
filterSubMenuItem1,
filterSubMenuItem2,
};
void tree::OnMenuCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID )
{
TreeListMenu *menu= tree->CreateMenu();
TreeListMenu *submenu = tree->CreateMenu();
if(node==NULL)
{
menu->AddMenuItem(RemovetopNode,"Remove Top Node","delete");
menu->AddMenuItem(CheckedMenuItem,"Checked Menu Item");
menu->AddMenuItem(DefaultMenuItem,"Default Menu Item");
menu->AddSeperator();
menu->AddMenuItem(DialogLaunchMenuItem,"DialogLaunchMenuItem");
menu->AddMenuItem(DisableMenuItem,"DisableMenuItem");
menu->AddMenuItem(HiddenMenuItem,"HiddenMenuItem");
menu->AddMenuItem(IconMenuItem,"IconMenuItem");
menu->SetItemDefault(DefaultMenuItem,true);
menu->SetItemChecked(CheckedMenuItem,true);
menu->SetItemDialogLaunching(DialogLaunchMenuItem,true);
menu->SetItemDisable(DisableMenuItem,true);
menu->SetItemHidden(HiddenMenuItem,true);
menu->SetItemIcon(IconMenuItem,"sketch");
menu->SetItemText(RemovetopNode,"Remove Top Nodes");
// submenu
submenu->AddMenuItem( SubMenuItem1,"Model Views");
submenu->AddMenuItem( SubMenuItem2,"Cameras");
submenu->AddMenuItem( SubMenuItem3,"Model History");
submenu->AddMenuItem( SubMenuItem4,"History Model");
menu->SetSubMenu(RemovetopNode,submenu);
}
else
{
if(node==modelhistoryNode)
{
menu->AddMenuItem(modelhistoryfilter,"Filter");
// submenu
submenu->AddMenuItem( filterSubMenuItem1,"Remove Item");
submenu->AddMenuItem( filterSubMenuItem2,"Remove All But Item");
menu->SetSubMenu(modelhistoryfilter,submenu);
}
else if (node==historyModeNode)
{
menu->AddMenuItem(historymenu,"History Mode");
menu->AddMenuItem(nohistorymenu,"History-Free Mode");
menu->SetItemIcon(historymenu,"check");
}
}
tree_control0->SetMenu(menu);
delete menu;
delete submenu;
}
NX二次开发treelist控件添加右键快捷菜单回调函数的简单例子
这里大概的模拟了下 部件导航器的功能!
页:
[1]