Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-12-10
5
Medium Priority
?
973 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:James Atkin
[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:James Atkin
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 400 total points
ID: 9911385
OK, now it is clear. <Force the toolbar to update> is:

CWinApp::OnIdle(0);
0
 
LVL 4

Author Comment

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

Thanks for your help...

James
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

730 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