Application does not terminate on shutdown

I coded an application with delphi2 which runs in the system tray.
I am using the TrayIcon component for this.
But when shutting down Windows while my application runs, it does only terminate if it is not minimized.
Seems as if it could have something to do with TrayIcon...

Of course I read several FAQs on this topic and found some hints concerning WM_QUERYENDSESSION and WM_ENDSESSION, but if my application is minimized the message handler does not even get the WM_QUERYENDSESSION message.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hmmm. I wrote a trayicon component once which in its first revision had this problem... I had not added handling for WM_QUERYENDSESSION to the trayicons message handler. This could very well be the problem, try to return 1 for this message in the trayicons windowproc. If you've got source, please post the message handler and I'll look at it.

Regards,

Erik.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

A Delphi2 component designed to make creating SystemTray icons easier.
Adding this component to a form, and when the control is active, the
application will minimize to the SystemTray instead of the TaskBar.
A popup menu may be made available (via a right-click on the icon).

The component operates in two modes - if the "SeparateIcon" property is
False (default), then the SysTray icon only appears when/if the application
is minimized. Setting the "SeparateIcon" property true allows both taskbar
and SystemTray icons to appear, and also a SystemTray icon when the
application isn't minimized.

Requires Delphi 2.0 (32-bit), and either Windows95 or Windows-NT v4.0
Component will compile and run with NT v3.51; but functionality is
automatically disabled (NT v3.51 doesn't have a SystemTray).

This component is Freeware, as were those it was based on. You may freely
use this component in any Application (be it Commercial, Shareware, or
Freeware) without fee or royalty, provided this copyright notice remains
intact. Some minor form of recognition for commercial or shareware software
would be nice.
}

if not (csDesigning in ComponentState)
then
begin
StrPLCopy(fData.szTip,fHint,SizeOf(fData.szTip)-1);
if fHint <> ''
then
fData.uFlags:=fData.uFlags OR NIF_Tip
else
fData.uFlags:=fData.uFlags AND NOT NIF_Tip;
UpdateTrayIcon;
end;
end;
end;

if Assigned(fOnRightClick)
then
fOnRightClick(Sender,mbRight,[],CursorPos.X,CursorPos.Y);
end;

procedure TTrayIcon.HandleMinimize(Sender:TObject);
begin
if fActive
then
begin
ShowWindow(Application.Handle,SW_Hide);
if fNoTrayIcon
then
AddIconToTray;
end;
fMinimized:=True;
if Assigned(fOnMinimize)
then
fOnMinimize(Sender);
end;

procedure TTrayIcon.HandleRestore(Sender:TObject);
begin
if fActive
then
begin
ShowWindow(Application.Handle,SW_Restore);
if not fSeparateIcon
then
RemoveIconFromTray;
end;
if Assigned(fOnRestore)
then
fOnRestore(Sender);
fMinimized:=False;
end;