Solved

change a menu item's text

Posted on 2001-07-30
3
388 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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. …
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.

733 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