Solved

change a menu item's text

Posted on 2001-07-30
3
382 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
3 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now