Solved

changing button state enabled to disabled!

Posted on 2003-11-13
3
275 Views
Last Modified: 2013-11-20
hi!
During the course of the program, I want to change the state of the button from enabled to disabled, the button property is set to Enabled at the start of the program, when the window is displayed, Once I start the process of importing a file, I want to disable the Exit button provided so that the user is not able to stop the program.
Any ideas..
please help
thanks
rahul
0
Comment
Question by:Rahulsaxena
3 Comments
 
LVL 3

Accepted Solution

by:
freewell earned 50 total points
Comment Utility
If it is in a dialogbox.
GetDlgItem(ID_EXIT)->EnableWindow(FALSE);

0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
I want to disable the Exit button provided so that the user is not able to stop the program.

the code from freewells above will cope with a button.  If it is on the toolbar use the OnUpdateCommandUI functionality.

HOWEVER if you do not provide some sort of message pumping the user can click as many times as he likes on the button and nothing should happen.  Also see what happens if the user switches to another app and back to yours re redrawing the screen.
If the progress takes a long time you may want to display a progress bar.
0
 
LVL 8

Expert Comment

by:martynjpearson
Comment Utility
If you also need to stop users from closing the app by clicking the cross in the top right hand corner, the best bet is to override OnCancel if it is a dialog, and to not call the base class OnCancel() if you are still processing, thus:

void CMyDialog::OnCancel()
{
    if (m_bProcessing) // Some flag that indicates processing is taking place
      AfxMessageBox("Cannot close application during processing");
   else
      OnCancel();
}

All the best
Martyn
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

18 Experts available now in Live!

Get 1:1 Help Now