Solved

change a menu item's text

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 172
Define unique primary key 9 89
tripleUp challenge 7 74
EvenOdd challenge 10 90
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…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

911 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

20 Experts available now in Live!

Get 1:1 Help Now