Board index » delphi » Terminate without executing other Form.Creates ??

Terminate without executing other Form.Creates ??

Hi everyone,

I have a problem with terminating my application. I am using several
tables and a query which should be opened in the create event of my
main form.
Before that I retrieve the directory of my database from an INI-file
an set this as the DataBase property of the datasets.

Problem:

If one of the datasets cannot be opened correctly (maybe the directory
was wrong), I would like to terminate the application using
  Application.Terminate;
But before it finally exits, the Create-procedures of all the other
forms are called first. And since they try to access my still closed
tables and queries I get lots of Errors.

How can I terminate the application IMMEDIATELY?

Thanks,

  Christian

--------------  Ich habe Windows 95  (flames welcome)  -----------------
       Christian Kaupa                              Tel:  ++49-8531/8540
       ka...@fmi.uni-passau.de                      Fax:  ++49-8531/8538

 

Re:Terminate without executing other Form.Creates ??


In article <326E61D6.3...@fmi.uni-passau.de>, From Christian Kaupa
<ka...@fmi.uni-passau.de>, the following was written:

Quote
> I have a problem with terminating my application. I am using several
> tables and a query which should be opened in the create event of my
> main form.
> Before that I retrieve the directory of my database from an INI-file
> an set this as the DataBase property of the datasets.

> Problem:

> If one of the datasets cannot be opened correctly (maybe the directory
> was wrong), I would like to terminate the application using
> Application.Terminate;
> But before it finally exits, the Create-procedures of all the other
> forms are called first. And since they try to access my still closed
> tables and queries I get lots of Errors.

Hi Christian(nice name!),

To save resources you should create your other forms only when you need
them but if you want them all created initially then create them from
the main form after your tables are opened. Try this in your on Create
event:

try
    Table1.open;
    Table2.open;
    Table3.open;
    Form2 := TForm2.Create(Application);   {these should really be
created only when needed}     Form3 := TForm3.Create(Application);
except
    Application.Terminate;
end;

To do the above you will need the other units added to the uses clause
of the main form and disable the autocreate of your forms in the project
options.

God Bless,

--
Jay Schwisow j...@weldnet.com
10/23/96 19:37
---------
Using: OUI PRO 1.5.0.2 from http://www.dvorak.com

Re:Terminate without executing other Form.Creates ??


  Look in the DPR file (project source).

  Before the CreateForm call, make a test and don't call this procedure
is you must terminate your application directly.

Quote
Christian Kaupa <ka...@fmi.uni-passau.de> wrote:
>Hi everyone,

>I have a problem with terminating my application. I am using several
>tables and a query which should be opened in the create event of my
>main form.
>Before that I retrieve the directory of my database from an INI-file
>an set this as the DataBase property of the datasets.

>Problem:

>If one of the datasets cannot be opened correctly (maybe the directory
>was wrong), I would like to terminate the application using
>  Application.Terminate;
>But before it finally exits, the Create-procedures of all the other
>forms are called first. And since they try to access my still closed
>tables and queries I get lots of Errors.

>How can I terminate the application IMMEDIATELY?

>Thanks,

>  Christian

>--------------  Ich habe Windows 95  (flames welcome)  -----------------
>       Christian Kaupa                              Tel:  ++49-8531/8540
>       ka...@fmi.uni-passau.de                      Fax:  ++49-8531/8538

--

           ___                                              ___
           L_|_                                            _|_J
          ( -O>                                            <O- )
       ___//\J  __________________________________________  L/\\___
      //-,\    |                                          |    /,-\\
     || / \\   L   AVONTURE Christophe (c) AVC Software   J___// \ ||
   _ ''/\/ '---J    Christophe.Avont...@is.belgacom.be    L---' \/\'' _
  / \ //\\.    |__________________________________________|    .//\\ / \
 |_/\'/  ||                                                    ||  \'/\_|
      '   ||_       "Postings are personnal, and don't        _||   '
          |__)         reflect Belgacom's opinion"           (__|

               SWAG: http://www.gdsoft.com/swag/swag.html              

                        ftp://ftp.gdsoft.com/swag/

Re:Terminate without executing other Form.Creates ??


Quote
> Problem:

> If one of the datasets cannot be opened correctly (maybe the directory
> was wrong), I would like to terminate the application using
>   Application.Terminate;
> But before it finally exits, the Create-procedures of all the other
> forms are called first. And since they try to access my still closed
> tables and queries I get lots of Errors.

> How can I terminate the application IMMEDIATELY?

> Thanks,

>   Christian

HALT(1);

Re:Terminate without executing other Form.Creates ??


Christian Kaupa <ka...@fmi.uni-passau.de> wrote in article
<326E61D6.3...@fmi.uni-passau.de>...

Quote
> Hi everyone,

> I have a problem with terminating my application. I am using several
> tables and a query which should be opened in the create event of my
> main form.
> Before that I retrieve the directory of my database from an INI-file
> an set this as the DataBase property of the datasets.

> Problem:

> If one of the datasets cannot be opened correctly (maybe the directory
> was wrong), I would like to terminate the application using
>   Application.Terminate;
> But before it finally exits, the Create-procedures of all the other
> forms are called first. And since they try to access my still closed
> tables and queries I get lots of Errors.

> How can I terminate the application IMMEDIATELY?

Raise an exception after calling Application.Terminate. You can then catch
this exception in your project file to either display an appropriate error
dialog (or just to hide the default error message if you have already
displayed an appropriate error message).

Re:Terminate without executing other Form.Creates ??


Quote
Christian Kaupa <ka...@fmi.uni-passau.de> wrote:
>>How can I terminate the application IMMEDIATELY?

use the HALT method.  It does exactly what you want.

Christopher di Armani
Dolphin Software Solutions

Other Threads