How to change Menu caption dynamically?
-
I have a menu "Options" with one submenu "Start" Options>Start How can i change the caption of "Start" to "Stop" when i click the menu?
Handle the
ON_UPDATE_COMMAND_UI
event for your "Start"/"Stop" menu item and then in that handler function something along the lines of...if(bStartMode)
pCmdUI->SetText("Start");
else
pCmdUI->SetText("Stop");You could have code in the
ON_COMMAND
event handler to toggle the mode from start to stop. Hope this helps. :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp -
Handle the
ON_UPDATE_COMMAND_UI
event for your "Start"/"Stop" menu item and then in that handler function something along the lines of...if(bStartMode)
pCmdUI->SetText("Start");
else
pCmdUI->SetText("Stop");You could have code in the
ON_COMMAND
event handler to toggle the mode from start to stop. Hope this helps. :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp -
I tried that, but i doesnt work. I'm using VC++6 with SP5 and my program is a dialog based program.
void CTestUImageDlg::OnUpdateFileExit(CCmdUI* pCmdUI) { pCmdUI->SetText("Start"); }
Nothing happens! Why??!!Why have you put the code in the update handler for FileExit? You need to put it into the update handler for the menu item Start in the options menu. Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fuity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain) -
Why have you put the code in the update handler for FileExit? You need to put it into the update handler for the menu item Start in the options menu. Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fuity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)I know that, i was testing if my Exit menu item will change it's caption. It was a test app, which does nothing. Just a menu with File>Exit. Clicking the Exit does not execute any function. So i just wanted to test if the caption changes, but it doesnt! Why?
-
I know that, i was testing if my Exit menu item will change it's caption. It was a test app, which does nothing. Just a menu with File>Exit. Clicking the Exit does not execute any function. So i just wanted to test if the caption changes, but it doesnt! Why?