void wxFrameBase::SetMenuBar(wxMenuBar *menubar) { if ( menubar == GetMenuBar() ) { // nothing to do return; } DetachMenuBar(); this->AttachMenuBar(menubar); }
void wxFrame::SetMenuBar( wxMenuBar* pMenuBar ) { wxString sError; if (!pMenuBar) { DetachMenuBar(); // // Actually remove the menu from the frame // m_hMenu = (WXHMENU)0; InternalSetMenuBar(); } else // set new non NULL menu bar { m_frameMenuBar = NULL; // // Can set a menubar several times. // TODO: how to prevent a memory leak if you have a currently-unattached // menubar? wxWidgets assumes that the frame will delete the menu (otherwise // there are problems for MDI). // if (pMenuBar->GetHMenu()) { m_hMenu = pMenuBar->GetHMenu(); } else { pMenuBar->Detach(); m_hMenu = pMenuBar->Create(); if (!m_hMenu) return; } InternalSetMenuBar(); m_frameMenuBar = pMenuBar; pMenuBar->Attach((wxFrame*)this); } } // end of wxFrame::SetMenuBar