Print Page | Close Window

Changing menu at runtime

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=3269
Printed Date: 06 October 2024 at 2:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing menu at runtime
Posted By: wal33604
Subject: Changing menu at runtime
Date 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?





Replies:
Posted By: wal33604
Date 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 );




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net