Solved

changing button state enabled to disabled!

Posted on 2003-11-13
3
286 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 156
centeredAverage challenge 8 181
abstract class with all non abstract mentods 6 80
Modbus - whats the maximum I can store in one register? 4 80
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

821 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