Solved

Forms at Program End

Posted on 1999-01-08
3
146 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
ID: 1355315
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
ID: 1355316
Or you could put it into the dpr file right after the Application.Run.

Regards, Madshi.
0
 
LVL 2

Expert Comment

by:SupWang
ID: 1355317
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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