Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First opportuniry to close application? 2

Status
Not open for further replies.

TimSNL

Programmer
Sep 11, 2001
119
0
0
AU
Hello.

Inside the OnCreate event of my main form I do a version upgrade, creating any new database fields my application needs. If this version upgrade fails I don't want my program to start.

I understand that it is not a good idea to close a form from within its own OnCreate procedure.

What is the earliest opportunity I have to kill the application? I don't want the application to start if the version upgrade fails.

Thanks
Tim
 
you can try to add this line into your OnCreate event:
Application.Terminate;

Hope it's help.
 
If you go to "view unit", you will find a unit with the name of the project. This typically has a long-winded uses clause followd by something like:

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

You can edit the bits between "Initialize" and "Run". Here is an example from one of my apps:

begin
Application.Initialize;
Application.Title := 'Thunderbird';
Application.CreateForm(TDataModu, DataModu);
if not DataModu.Initialise then begin
DataModu.Free; {Get error if allow it to free later}
Exit;
end;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

"DataModu.Initialise" happens to be a version upgrade routine.

Have fun
Simon
 
Thanks for both your answers :)

Application.Terminate is the quick option I will use this time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top