Article View: borland.public.cppbuilder.nativeapi
Article #2304Re: My app closes, but cancels Windows shutdown?
From: Mark Jacobs
Date: Mon, 12 Mar 2007 10:37
Date: Mon, 12 Mar 2007 10:37
30 lines
2175 bytes
2175 bytes
I do it using a form-wide flag (bool clsing) to tell OnCloseQuery whether the
request to close is from the user or the OS, like this :-
//---------------------------------------------------------------------------
void __fastcall TForm1::WndProc(TMessage &Message)
{
if (Message.Msg==WM_QUERYENDSESSION) clsing=true;
TForm::WndProc(Message);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if (!clsing)
{
ok=yorn("Are You Sure You Would Like to Exit");
if (!ok) { CanClose=false; return;}
}
CanClose=true; wrcfg();
delete mjtreg; delete curv; delete curs; delete vnms; delete txttoadd;
delete monlns; delete xpnd;
delete lavs; delete knms; delete jnki; delete svit;
if (BitBtn1->Enabled) if (yorn("Save Changes to Keys List"))
Memo1->Lines->SaveToFile(keyfnm);
}
//---------------------------------------------------------------------------
HTH,
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
Technical Details
Message-ID:
<45f52d0f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<Xns98ED90968E734anonymoushotmailcom@207.105.83.66>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,346f60f70c29a156 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Jacobs" <http://www.jacobsm.com/mjmsg.htm?BorlandNG> Newsgroups: borland.public.cppbuilder.nativeapi References: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66> Subject: Re: My app closes, but cancels Windows shutdown? Date: Mon, 12 Mar 2007 10:37:34 -0000 Lines: 31 Organization: DK Computing MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 81.144.157.8 Message-ID: <45f52d0f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1173695759 81.144.157.8 (12 Mar 2007 03:35:59 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail