Menubar / Toolbar problem
Hi .. I need to activate and deactivate Menubar and Toolbar time to time.
I have written code :
CWnd * pFrame = (CWnd *)AfxGetMainWnd();
CMenu * menu = pFrame->GetMenu();
for (int mq = 0;mq < menu->GetMenuItemCount();mq++)
menu->EnableMenuItem(mq,MF_BYPOSITION|MF_GRAYED);
pFrame->DrawMenuBar();
I just change attibute MF_GRAYED to MF_ENABLED as required.
This works fine with MenuBar but there is a problem with ToolBar .
Toolbar Enable/Disable doesnot happen properly.
PL Guide
Thanking you ...
Re: Menubar / Toolbar problem
There is an ON_UPDATE_COMMAND_UI mechanism in MFC to enable/disable menu items as well as toolbar buttons
Re: Menubar / Toolbar problem
Victor Sir , I am using ON_UPDATECOMMAND_UI to Enable/Disable Menu Items .
Here , I have a Replay Old Files option in my software. While Replaying the old file , I wish to disable the whole MenuBar and ToolBar . Once Replay is over , the user presses Escape and he is back to the routine software.
So I call DrawMenuBar function with attributes MF_GRAYED and MF_ENABLED.
Sometimes this works fine.
Sometimes , the MenuBar is active but Toolbar remains inactive.(Though Toolbar IDS are same as MenuItem ids). Sometimes the MenuBar is disabled but Toolbar remains enabled.
So I am confused.
PL guide.Thanking you ...
Re: Menubar / Toolbar problem
Quote:
Originally Posted by
new_2012
[...]
So I call DrawMenuBar function with attributes MF_GRAYED and MF_ENABLED.
[...]
Confused... :)
How did you that?
Both CWnd:: DrawMenuBar and :: DrawMenuBar functions take no arguments.
Re: Menubar / Toolbar problem
ovidiucucu sir , I set Menu Item property to either MF_ENABLED or MF_GRAYED , and then call DrawMenuBar ..
Sometimes It takes proper attributes and sometimes it does not ..
So I am confused
Re: Menubar / Toolbar problem
Is this confusing, too?
Quote:
Originally Posted by
VictorN
There is an
ON_UPDATE_COMMAND_UI mechanism in MFC to enable/disable menu items as well as toolbar buttons
I see it neat and clear. ;)