Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to change complete frame menu at runtime with LoadMenuBar() Collapse All
Subject Author Date
Andreas Mettauer Jul 29, 2004 - 9:01 AM

I have an MDI application, where I have to exchange the frame menu IDR_MAINFRAME by some other (IDR_DYNAMIC). So it’s not just replaceing some menuitems, it’s loading a new menu resource.


I tried this in some event handler:

...::OnChangeEditMode()
{
  if (g_bMode == mdEdit)
    m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME);
  else
    m_wndMenuBar.LoadMenuBar(IDR_DYNAMIC);
...


Unfortunately this asserts somewhere in ExtMenuControlBar::_GetActiveMdiChildWnd() Line 1152 (freeware version).


Is there any way to completely replace the menubar with another menu resource?

Technical Support Aug 1, 2004 - 8:14 AM

The LoadMenuBar method should not be used at runtime. Instead use the UpdateMenuBar method which invokes the _UpdateMenuBar internal virtual method of the CExtMenuControlBar class. This allows you to override the _UpdateMenuBar method in your own menu bar class and perform the custom initialization of menu bar’s buttons. Although this way is a bit complicated, but it is a single valid solution to your task.