-
August 24th, 2013, 01:39 AM
#1
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 ...
-
August 24th, 2013, 01:56 AM
#2
Re: Menubar / Toolbar problem
There is an ON_UPDATE_COMMAND_UI mechanism in MFC to enable/disable menu items as well as toolbar buttons
Victor Nijegorodov
-
August 24th, 2013, 03:20 AM
#3
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 ...
-
August 24th, 2013, 05:16 AM
#4
Re: Menubar / Toolbar problem
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.
-
August 24th, 2013, 05:25 AM
#5
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
-
August 24th, 2013, 06:59 AM
#6
Re: Menubar / Toolbar problem
Is this confusing, too?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|