Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Changing menu at runtime
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing menu at runtime

 Post Reply Post Reply
Author
Message
wal33604 View Drop Down
Newbie
Newbie


Joined: 10 November 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote wal33604 Quote  Post ReplyReply Direct Link To This Post Topic: Changing menu at runtime
    Posted: 24 November 2005 at 7:40am
Using Xtreme Toolkit Pro 9.51

I am working on an application that must change modes at runtime (meaning the menu and toolbars must be completely swapped). I first remove the current menu and toolbars using code similar to the following:


CXTPCommandBars* pCommandBars = m_mainFrame->GetCommandBars();
int barCount = pCommandBars->GetCount();
for ( int i = 0; i < barCount; ++i )
{
  pCommandBars->Remove( pCommandBars->GetAt( 0 ) );
}


This works all fine and well. However, when I go to set a new menu using CXTPCommandBars::SetMenu() I get a debug assertion on line 134 of XTPCommandBars.cpp where it checks to see of the CXTPMenuBar* is NULL. The program continues producing the desired results after the assertion.

My questions:
Is this is something that can be ignored since the error won't be produced in a Release build (although it will get annoying while debugging).
Is there way to do what I need to do that will not produce the assertion?


Back to Top
wal33604 View Drop Down
Newbie
Newbie


Joined: 10 November 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote wal33604 Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2005 at 8:42pm
I solved this by doing something similar to the following:


CXTPCommandBars* pCommandBars = m_mainFrame->GetCommandBars();
int barCount = pCommandBars->GetCount();
int seed = 0;
for ( int i = 0; i < barCount; ++i )
{
  CXTPToolBar* pToolBar = pCommandBars->GetAt( seed );
  if ( pToolBar->GetType() == xtpBarTypeMenuBar )
    ++seed;
  else
    pCommandBars->Remove( pToolBar );
}
pCommandBars->GetMenuBar()->GetControls()->RemoveAl l();


Rather than using SetMenu to swap the menu I used

pCommandBars->GetMenuBar()->LoadMenuBar( IDR_MENU );

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.