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 » Changing a Menu Item String Collapse All
Subject Author Date
Michael Bailey Aug 16, 2006 - 2:55 PM

Hi,

I’ve been trying to change menu items text in the Main Frame of the application. I’ve been trying the following code:

CExtCmdManager::cmd_t * p_cmd;
p_cmd = g_CmdManager->CmdGetPtr("MyPtofile", MENU_ITEM_ID );
ASSERT( p_cmd != NULL );
p_cmd->m_sMenuText = _T( "Some New Text" );
p_cmd->m_sToolbarText = _T( "Some New Text");

The code works to change the command string in the Customize Dialog list of commands, but does not change the string in the Main Fram menu itself. I’ve tried calling: RecalcLayout();
and m_wndMenuBar.UpdateMenuBar(); with no sucess.

Anyone know what I’m doing wrong?

Thanks,
Mike

Technical Support Aug 17, 2006 - 11:57 AM

Your code will work only for non-customizable applications. The customizable toolbars and menus are based on command trees. Each tree node in such a tree is an instance of the CExtCustomizeCmdTreeNode class which keeps current text for the command. The text stored in the CExtCmdItem class is default. You can reset the current text for any toolbar button and menu item to the default value when the Customize dialog is open. So, if you changes the CExtCmdItem members, you should also reset all the command tree nodes of this command. The resetting operation is based on traversing command trees of all the toolbars and menus. The CExtCustomizeSite::BuildToolbarLists() method allows you to get the list of all toolbars. The CExtCustomizeSite::GetToolbarCmdNode() method gets the initial/current command tree nodes of the customizable toolbar. The CExtCustomizeSite::MenuInfoGetCount() / CExtCustomizeSite::MenuInfoGetAt() method allows you to enumerate all the CExtCustomizeSite::CCmdMenuInfo menu information objects for all the documents/views. The CExtCustomizeSite::CCmdMenuInfo::GetNode() method gets the initial/current command tree nodes of the menu line.