PDA

View Full Version : Add menu in the main menubar with the sdk


alimae
02-01-2010, 09:17 AM
Hello,

In my plugin (.gup), I try to add a menu in the mainMenuBar. I’ve added the following code in the Start() method :



IMenuManager * menuManager = Max()->GetMenuManager();
IMenu * mainMenuBar = menuManager->GetMainMenuBar();
m_dynamicMenu = new DynamicMenu(&m_menuCallback);
// m_menuCallback is a "DynamicMenuCallback"

m_dynamicMenu->BeginSubMenu(GetString(IDS_MENU));
m_dynamicMenu->AddItem(0, ID_DO_SMTHG, GetString(IDS_DO_SMTHG));
m_dynamicMenu->EndSubMenu();

// link the current menu to the 3ds main menu bar :
mainMenuBar->AddItem(m_dynamicMenu->GetMenu()->GetItem(0), -1);

// update :
menuManager->UpdateMenuBar();



And in the stop function i have :

if(m_dynamicMenu)
{
IMenuManager * menuManager = Max()->GetMenuManager();
menuManager->GetMainMenuBar()->RemoveItem(m_dynamicMenu->GetMenu()->GetItem(0));

menuManager->UpdateMenuBar();

delete m_dynamicMenu;
m_dynamicMenu = NULL;
}


It works fine the first time i launch 3dsMax (i see menu and the menu callback works fine) but the next times, 3dsmax crashes at launch.
Any ideas? (or a good tutorial/link on how add menus with the sdk...)

Thanks.

CGTalk Moderation
02-01-2010, 09:17 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.