Solved

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

Posted on 2003-12-10
5
955 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 76
Prevent this page from creating additional dialogs. 3 390
conditional code and condition difference 9 77
Not needed 13 93
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: 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…
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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now