PDA

View Full Version : how to add menuitem with sdk?


CGGD
05-19-2010, 09:41 AM
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?

CGTalk Moderation
05-19-2010, 09:41 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.