Changing the string of a menuitem dynamically

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all! I am building a MFC MultiDoc App and I nedd to change the string shown in a menu item at runtime. I tried:

<span style="font-size:small
CString str =
<span style="color:#a31515; font-size:small <span style="color:#a31515; font-size:small "&New Menu Item"<span style="font-size:small , str2;<a> <span style="font-size:small
CMenu m_Menu, *p_subMenu =
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small new<span style="font-size:small CMenu();<a> <span style="font-size:small
m_Menu.LoadMenuA(IDR_MY_MENU;
p_subMenu = m_Menu.GetSubMenu(4);
p_subMenu->ModifyMenuA(2, MF_BYPOSITION|MF_STRING, ID_TOOLS_T, str);
// ID_TOOLS_T is the ID of the menu item that has to be changed. ID_TOOLS_T is the 3rd menu item of submenu pointed by p_subMenu,
// which stays at position 5 of IDR_MY_MENU.

The whole program compiles OK, but the menu item won´t be changed. What is missing?
I am trying to change the menu inside my CApp file ... perhaps I am supposed to change it somewhere else ...

Thanks

Jorge Teixeira

<hr class="sig Jorge Teixeira

View the full article
 
Back
Top