Solved

Enabling & Disabling Toolbar items at runtime in MFC SDI...

Posted on 2003-12-10
5
971 Views
Last Modified: 2013-11-20
Hi,

I have an SDI application containing a Menu (IDR_MENU) and a Toolbar (IDR_TOOLBAR1).

When a perform click a certain button or menu item (RUN), I want specific menu items and Toolbar icons to become disabled.  Each associated Toolbar Icon and Menu Item have the same ID (ID_ABORT for example).

I use the following to disable the 'Abort' functionality when it is NOT running...

void CMainFrame::OnUpdateFileAbort(CCmdUI* pCmdUI)
{
   if (isRunning == false) pCmdUI->Enable(FALSE);
}

This works fine for the Menu item, but does not change the Toolbar icon.

Any ideas where I am going wrong...

James
0
Comment
Question by:jatkin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9911325
void CMainFrame::OnUpdateFileAbort(CCmdUI* pCmdUI)
{
  pCmdUI->Enable(! running);
}

This should work in standard SDI application created by MGC Application Wizard. Just set running flag when necessary.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9911345
Please make sure that the toolbar is also using the same id.
0
 
LVL 4

Author Comment

by:jatkin
ID: 9911366
I get the same response - Menu works as expected, Toolbar does not change.  IDs are the same in the Menu & Toolbar...

As the function that sets the variable to enable & disable the toolbar & menu items is sequencial, do I need to FORCE some sort of update to occur DURING its execution ?

i.e.
void CMyView::DoIt()
{
   Running = true;
   <Force the toolbar to update>
   ... Do some stuff ...
   <Force the toolbar to update>
   Running = false;
}
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 100 total points
ID: 9911385
OK, now it is clear. <Force the toolbar to update> is:

CWinApp::OnIdle(0);
0
 
LVL 4

Author Comment

by:jatkin
ID: 9911409
As usual, you are an absolute genius!!!!

Thanks for your help...

James
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 173
Whole sheet autoscrub still needed 19 55
abstract class with all non abstract mentods 6 87
x-bar in Google Sheets 2 129
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

752 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