🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15414

Re: How to terminate a application immediately

#15414
From: Remy Lebeau (TeamB)
Date: Sat, 05 Jul 2003 00:34
26 lines
1983 bytes
"HuangC" <HuangC@motic.com.cn> wrote in message
news:3f0238c6$1@newsgroups.borland.com...

> I want to terminate a application immediately
> when the initialize some object failed in the
> construct funtion.I try to use
> Application->Terminate(); return;
> but the application continue creating other
> forms however.

Application->Terminate() simply posts a WM_QUIT message to the message
queue, which will not be processed until later on when the queue begins
being pumped for messages.

If you are doing your initialization in the MainForm's constructor, then
simply throw an exception to indicate a failure.  An exception is the only
way to return a failure from a constructor.  Throwing an exception from the
MainForm will prevent the other forms from being created.

The alternative is to alter the project's WinMain() function directly, to do
your initializations before the first form is ever created.  Then you can
bort your program more gracefully when needed.


Gambit
Technical Details
Message-ID: <3f061be1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f0238c6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2d8349b0d005c697
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-04 17:39:41 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f0238c6$1@newsgroups.borland.com>
Subject: Re: How to terminate a application immediately
Date: Fri, 4 Jul 2003 17:34:00 -0700
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3f061be1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1057364961 207.175.226.26 (4 Jul 2003 17:29:21 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail