?
Solved

change a menu item's text

Posted on 2001-07-30
3
Medium Priority
?
403 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 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