Board index » delphi » Cannot ShutDown with D2 App Running, why?

Cannot ShutDown with D2 App Running, why?

I'm using:

ShowWindow(Application.Handle, SW_HIDE);

To hide the App from the TaskBar and I am using TrayIcon to put the
icon in the tray.

BUT, this prevents Win95 from shutting down properly because I think
it HIDES it from Win95, which, when attempting to shutdown, doesn't
find the file and simply returns to the desktop.

BUT WHY?!?

Also, during ShutDown, the CLOSE event or CLOSEQUERY event isn't
fired, so I can't use SW_SHOW or SW_RESTORE to get the app back just
before it closes?

For some reason Win 95 during shutdown executes an END TASK rather
than a CLOSE for each app running?

In any case, I need a way around this and I've already spent several
hours looking through the books and help to no avail!!!

 

Re:Cannot ShutDown with D2 App Running, why?


You need to add a message handler for WM_QUERYENDSESSION and set the passed
Msg.Result to 0

e.g

declare as part of form

    procedure CanEnd(var msg : TMessage) ; message WM_QUERYENDSESSION;

implementation

procedure TForm1.CanEnd(var msg : TMessage);
begin
     msg.Result := 0;
end;

HTH

David W. Yutzy <10...@utech.net> wrote in article
<31f9a17f.168190...@news.utech.net>...

Quote
> I'm using:

> ShowWindow(Application.Handle, SW_HIDE);

> To hide the App from the TaskBar and I am using TrayIcon to put the
> icon in the tray.

> BUT, this prevents Win95 from shutting down properly because I think
> it HIDES it from Win95, which, when attempting to shutdown, doesn't
> find the file and simply returns to the desktop.

> BUT WHY?!?

> Also, during ShutDown, the CLOSE event or CLOSEQUERY event isn't
> fired, so I can't use SW_SHOW or SW_RESTORE to get the app back just
> before it closes?

> For some reason Win 95 during shutdown executes an END TASK rather
> than a CLOSE for each app running?

> In any case, I need a way around this and I've already spent several
> hours looking through the books and help to no avail!!!

Other Threads