0

The whole day I am trying to solve this simple issue, but without any success. I found a lot of hints in internet, but seems, that none of them is valid for my problem.

My issue is quite simple: I want to change the caption of a menue item while runtime

But it seems, that all solutions I found are very specific.

My requirements are this: - it is a MFC application (VS2010) - It is a SDI application, not MDI - I want to change the caption of a main menu item (like "File"), not an entry of a submenue.

Because of main entry item, there is no ID for the menu item. Therefore solutions with ON_UPDATE_COMMAND_UI will not work!

My problems are: - either the code I tried, is generating an assertion or exception - or the function call returns with false - or the function seems to work well, but I do not see any result (the caption is still unchanged)

Maybe I am using the wrong functions, or the wrong place for calling the functions. Has anybody an example, which would work within my application pre-conditions?

Many, many thanks!

Richard

NBGer
  • 1

1 Answers1

2

Windows cleverly hides the function to modify a menu under the arcane name of ModifyMenu. I hate it when they do things like that. Really makes me wish for Linux/Unix, with nice clear names like shmdt and mvwaddchnstr. Anyway, getting off my soap box for the moment, you'd call it something like this:

GetParentFrame()->GetMenu()->ModifyMenuW(1, MF_BYPOSITION, 0, L"New Item");
GetParentFrame()->Invalidate();
Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Hello, I tried your code. But it failes. From where I need to call this ModifyMenu() ? I added the code in my CFormView Class, in OnInitialUpdate. But the call is causing an exception :-( – NBGer Nov 07 '14 at 11:47