mfc >> Renaming menu item and changing its prompt text...?

by HS » Wed, 26 Nov 2003 19:05:10 GMT

Hi,

I rename one menu item at runtime as follows...

int nCount = pMenu->GetMenuItemCount();

for (int i = 0; i < nCount; i++)
{
CString str;
pMenu->GetMenuString(i, str, MF_BYPOSITION);

if (str.CompareNoCase(_T("Old Name")) == 0)
{
UINT nId = pMenu->GetMenuItemID(i);
pMenu->ModifyMenu(nId, MF_BYCOMMAND, nId, _T("New
Name"));
break;
}
}

How can I change also its prompt text?

TIA,

-HS



mfc >> Renaming menu item and changing its prompt text...?

by Jeff Partch [MVP] » Wed, 26 Nov 2003 21:33:58 GMT






Paul DiLascia has a discussion of this topic in his C++ Q&A column from the
June 2000 issue of MSDN magazine...

http://www.msdn.microsoft.com/msdnmag/issues/0600/c/

--
Jeff Partch [VC++ MVP]





mfc >> Renaming menu item and changing its prompt text...?

by anonymous » Thu, 27 Nov 2003 03:17:53 GMT

>
Q&A column from the

Jeff, Thank you for your help!

-HS


Similar Threads

1. Change menu item text programmatically

I am trying to programmatically change the text of a menu item  in a submenu 
of context menu.
The menu item starts off as "Play" and I later execute
    this.menuItem1.Text = "Stop";
I can confirm with the debugger that the field value changes as expected yet 
this is not actually reflected in the menu itself.

Any ideas?

Mike 


2. Change Menu Item Text at Runtime

3. Change Menu item text at Runtime

Hi

How do i change menu item text at Runtime in MFC Dialog based
application.I am creating popup Menu on button click



///my code

CMenu m_Menu,*p_subMenu;
CString strMenuString;
CString strTMP;

m_Menu.LoadMenu(IDR_MY_MENU);
p_subMenu = m_Menu.GetSubMenu(0);
p_subMenu->GetMenuString(ID_ENABLE,strMenuString,MF_BYCOMMAND);
strTMP.LoadString(IDS_MENU_DISABLE);
if(strMenuString.CompareNoCase(strTMP)==0)
{
strMenuString.LoadString(IDS_MENU_ENABLE);
}
else
{
strMenuString.LoadString(IDS_MENU_DISABLE);
}

BOOL bChanged = p_subMenu->ModifyMenu(ID_MENU_ENABLE,MF_BYCOMMAND|
MF_STRING,ID_MENU_ENABLE,(LPCTSTR)strMenuString);

ASSERT(bChanged);

///////////////////////////////

I think i m doing some thing wrong in above code


Regards

Manoj Jangid

4. Status Bar prompts when mouse is hovering over a menu item in the

5. change menu prompt dynamically

hi,

I wanna change the menu prompt dynamically.
how can I do that?

regards.
Monica.L.

6. change the menu prompt dynamically

7. bold Main Menu Items and Popup Menu Items don't disply in Vista

Hi,
I use BCB 5
Combined with Mike L's Theme manager for XP style.

Yesterday I managed to download, install and check Vista public Beta.

The Menu Items which are bold (either in Main Menu or Popups) are always 
gone, they don't get displayed at all ?

Anybody else seen this ?
Has an explanation ?
Found a rememdy ? 


8. How to enable statusbar menu prompt with context menu