Notifications
Clear all

[Closed] how to add menuitem with sdk?


	Interface *MaxInterface= GetCOREInterface()
	IActionManager *MaxActionManager = MaxInterface->GetActionManager()
	IMenuManager *MaxMenuManager = MaxInterface->GetMenuManager()
	IMenu *MaxMainMenu = MaxMenuManager->GetMainMenuBar()
	IActionManager *MaxSctionManager = MaxInterface->GetActionManager()

	ActionTableId TestActionTableID = MaxActionManager->NumActionTables()
	ActionContextId TestActionContextID = 9456498;
	CStr TestActionName = GetString(0)

	ActionCallback *TestActionCallback = new ActionCallback()

	ActionTable *TestActionTable = new ActionTable(TestActionTableID,TestActionContextID,TestActionName)
	ActionItem *TestActionItem = TestActionTable->GetAction(TestActionContextID)
	MaxActionManager->RegisterActionTable(TestActionTable)
	MaxActionManager->ActivateActionTable(new ActionCallback(),TestActionContextID)
	TestActionTable->AppendOperation(new BaseAction())

	IMenu *TestMenu = GetIMenu()
	TestMenu->SetTitle("TestMenu")
	MaxMenuManager->RegisterMenu(TestMenu)
	IMenuItem *TestMenuItem = GetIMenuItem()
	TestMenuItem->SetTitle("TestMenuItem")
	TestMenuItem->SetActionItem(TestActionItem)
	TestMenu->AddItem(TestMenuItem)

	IMenuItem *TempMenuItem = GetIMenuItem()
	TempMenuItem->SetSubMenu(TestMenu)
   
	MaxMainMenu->AddItem(TempMenuItem)
	MaxMenuManager->UpdateMenuBar()

--------------
BOOL  BaseAction::ExecuteAction ()
{
	MessageBox(NULL,"TestMenu","TestMenuTite",MB_OK);
	return TRUE;
}


i want add the menuitem in mainmenu,if click it,display a messagebox
who can help me fix my code?