?
Solved

changing button state enabled to disabled!

Posted on 2003-11-13
3
Medium Priority
?
299 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
[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
3 Comments
 
LVL 3

Accepted Solution

by:
freewell earned 150 total points
ID: 9745313
If it is in a dialogbox.
GetDlgItem(ID_EXIT)->EnableWindow(FALSE);

0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9745796
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
ID: 9745933
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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