Board index » delphi » windows shutdown = app shutdown

windows shutdown = app shutdown

Hi Farouche,

try to insert an "Application.ProcessMessages"-call behind your luk-call.

But, why do you send a quit message to your own application at all?
It will terminate with no additional code, be sure.

And why did you use FormCloseQuery, if the only
possible reaction is "canclose := true"?
For your purpose FormClose is good enough. CloseQuery only
makes sense, if you'd like to intercept the termination of your
program under some circumstances.

Just try this version:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  trayicon1.IconVisible := false;;

  FileHandle.Addlinetolog('Exit', false);

  if ini.getOnL then
  SignOff;

  Application.ProcessMessages; //just to be sure they are all handled (I don't
know what SignOff does)

  Action := caFree;
end;

...and don't let your program "sleep" while it terminates, because maybe you
provocate timeouts elsewhere (e.g. in Windows).

Hope I could help
Robert

 

Re:windows shutdown = app shutdown


Quote
In article <88ogdt$a...@bornews.borland.com>, Farouche wrote:
> When windows is shutting down I want my app to close, so I call my closedown
> procedure from the onCloseQuery event and set the canclose to true.
> This should work and when windows is shutting down it closes my app just as
> it should but then the shutdown procedure stops and I have to select
> Shutdown again before windows shuts down.

The problem is probably caused by the trayicon component you are using. There
are several around that do not handle WM_QUERYENDSESSION correctly in the tool
window they are using to handle notifications. Try to replace the line

Quote
>   trayicon1.IconVisible := false;;

with

   trayicon1.free;
   trayicon1:= nil;

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:windows shutdown = app shutdown


Quote
In article <38B0316A.56B64...@planet-interkom.de>, Robert Kuhlmann wrote:
> And why did you use FormCloseQuery, if the only
> possible reaction is "canclose := true"?

MainForm.OnCloseQuery is the only event that you can guarantee gets called
no matter how the shut down is initiated.

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03/5.00)
 (Unsolicited e-mail replies will most likely be ignored)

Re:windows shutdown = app shutdown


Yes this makes sense but the problem is, that the app won't shutdown unless
I call the closedown procedure luk from FormCloseQuery.

Farouche

Quote
"Robert Kuhlmann" <robert.kuhlm...@planet-interkom.de> wrote in message

news:38B0316A.56B64219@planet-interkom.de...
Quote
> Hi Farouche,

> try to insert an "Application.ProcessMessages"-call behind your luk-call.

> But, why do you send a quit message to your own application at all?
> It will terminate with no additional code, be sure.

> And why did you use FormCloseQuery, if the only
> possible reaction is "canclose := true"?
> For your purpose FormClose is good enough. CloseQuery only
> makes sense, if you'd like to intercept the termination of your
> program under some circumstances.

> Just try this version:

> procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
> begin
>   trayicon1.IconVisible := false;;

>   FileHandle.Addlinetolog('Exit', false);

>   if ini.getOnL then
>   SignOff;

>   Application.ProcessMessages; file://just to be sure they are all handled
(I don't
> know what SignOff does)

>   Action := caFree;
> end;

> ...and don't let your program "sleep" while it terminates, because maybe
you
> provocate timeouts elsewhere (e.g. in Windows).

> Hope I could help
> Robert

Other Threads