Board index » delphi » Delaying shutdown of application.

Delaying shutdown of application.

I wish to delay the shutdown of my application after the user clicks on the
'exit application' system button (top right hand corner).  I am writing some
software using a modem and wish to reset certain parameters before closing the
application.  I send a command to the modem and then wait for a reply to ensure
the modem got the message.

If I use a timer, the application just exits without receiving the reply
message.  I could just write a while loop in the OnClose or OnDestroy events of
the form but that seems a bit crude.  Is there a way of intercepting the action
of clicking the system button such that I can close down the application when I
am finished.

Any comments or help would be most appreciated.

Chris Lord - TMS...@Aol.com

 

Re:Delaying shutdown of application.


Quote
TMSyst wrote:
> I wish to delay the shutdown of my application after the user clicks on the
> 'exit application' system button (top right hand corner).  I am writing some
> software using a modem and wish to reset certain parameters before closing the
> application.  I send a command to the modem and then wait for a reply to ensure
> the modem got the message.

> If I use a timer, the application just exits without receiving the reply
> message.  I could just write a while loop in the OnClose or OnDestroy events of
> the form but that seems a bit crude.  Is there a way of intercepting the action
> of clicking the system button such that I can close down the application when I
> am finished.

> Any comments or help would be most appreciated.

Intercept the OnCloseQuery event of one of the active windows. In this handler you
start a timer, start your clean-up work,  and set the CanClose boolean to 'false'.
This prevents the application being closed. After the timer elapsed, just destroy
the application, or set a flag which causes the OnCloseQuery handler to return
true, and then close the application normally.I use C++Builder but I assume this
works in Delphi too.
Quote
> Chris Lord - TMS...@Aol.com

Re:Delaying shutdown of application.


have you tried the event "OnCloseQuery"

procedure Form1.FormCloseQuery (Sender: TObject; var CanClose: boolean);
begin
  repeat
    (* showdown modem *)
  until true;
  CanClose := true;
end;
or something like this

--
Andreas Klein
eMail: a-k...@metronet.de

TMSyst schrieb in Nachricht
<1998051508352501.EAA08...@ladder01.news.aol.com>...

Quote
>I wish to delay the shutdown of my application after the user clicks on the
>'exit application' system button (top right hand corner).  I am writing
some
>software using a modem and wish to reset certain parameters before closing
the
>application.  I send a command to the modem and then wait for a reply to
ensure
>the modem got the message.

>If I use a timer, the application just exits without receiving the reply
>message.  I could just write a while loop in the OnClose or OnDestroy
events of
>the form but that seems a bit crude.  Is there a way of intercepting the
action
>of clicking the system button such that I can close down the application
when I
>am finished.

>Any comments or help would be most appreciated.

>Chris Lord - TMS...@Aol.com

Other Threads