Solved

Forms at Program End

Posted on 1999-01-08
3
144 Views
Last Modified: 2010-04-06
Hello,

I need to display a form that notice to user if a program configuration data could not be saved to disk (or familiar errors). The form has to appear when the Program is terminating or immediatly before that in other words.
I have tried to simply use Form.ShowModal in the OnClose-Event of the main form, but it didnt work, because the application was shutting down.

any ideas ?
0
Comment
Question by:omsec
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
SupWang earned 50 total points
Comment Utility
Why not use the OnCloseQuery event?
Description

Use OnCloseQuery to specify the conditions under which the form can close. An OnCloseQuery event handler contains a Boolean CanClose variable that determines whether a form is allowed to close. It's default value is True.
You can use an OnCloseQuery event handler to ask users if they are sure they really want the form closed immediately. For example, you can use the handler to display a message box that prompts the user to save a file before closing the form.
The TCloseQueryEvent type points to the method that determines whether a form can be closed. The value of the CanClose parameter determines if the form can close or not.

Example

When the user attempts to close the form in this example, a message dialog appears that asks the user if it is OK to close the form. If the user chooses the OK button, the form closes. If the user chooses Cancel, the form doesn't close.

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin
  if MessageDlg('Close the form?', mtConfirmation,
    [mbOk, mbCancel], 0) = mrCancel then
     CanClose := False;
end;
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Or you could put it into the dpr file right after the Application.Run.

Regards, Madshi.
0
 
LVL 2

Expert Comment

by:SupWang
Comment Utility
HI, omsec
If my answer is right, Please give the points to me. I haven't get points for a long time. :-)

Regards,SupWang

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

7 Experts available now in Live!

Get 1:1 Help Now