?
Solved

change a menu item's text

Posted on 2001-07-30
3
Medium Priority
?
395 Views
Last Modified: 2013-11-20
I'd like be able to change the text of a menu item at runtime.  In particular, I'm trying to change the text of the item which is normally edit->undo.  I'm going for the same idea like in MS Word where it says "Undo Typing" or if you format some text it'll say "Undo Bold", etc...

So how can I change this dynamically? The id will always be ID_EDIT_UNDO.

Thanks,
Marcus
0
Comment
Question by:marcus78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 6336523
Use the ClassWizard:

1) Open your CMainFrame, and press Ctrl+W
2) select ID_EDIT_UNDO from the list on the left side.
3) Select UPDATE_COMMAND_UI from the list on the right
4) Click [Add Function] (and OK it)
5) Click [Edit Code]
6) Make it so:

void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI)
{
    pCmdUI->SetText("Undo Typing");
}

=-=-=-=-=-=-=-

Note that the active View class will get a crack at the UI update first -- and it may have a default handler.  So if that doesn't work, open the CPP file for the desired View, then repeat steps 2 thru 6:

void CVwRichEd::OnUpdateEditUndo(CCmdUI* pCmdUI)
{
    pCmdUI->SetText("Restore Previous goodness.");
}


-- Dan
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6336780
If you don't use MFC than use SetMenuItemInfo API function. First you call GetMenu(hWnd), than GetSubMenu() for retrieving your "Edit" menu and than SetMenuItemInfo to set the new text.
0
 

Author Comment

by:marcus78
ID: 6338056
Whoa! I was completely overthinking that one.  Thanks, Dan!

Marcus
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question