Re:Program termination
The message <3bfd0976$0$25408$edfad...@dspool01.news.tele.dk>
from "Ole Borup" <olebo...@diku.dk> contains these words:
Quote
> Hi there
> I have a program which is located in the systray. When the user close the
> program, i use the folowing code to hide the program:
> procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
> begin
> Hide;
> CanClose := false;
> end;
> It works fine, but one thing. I can't shutdown the computer (Win95-Win2000).
> All other programs shutdown, but the system cannot shutdown my program. Is
> there a way to determine who is trying to shut down the program?
> - Ole
Hi, I have had the same problem with the tray icon from RXLIB. It happens
because the WM_QUERYENDSESSIOM message never arrives in the window
procedure of the tray icon so the tray icon can't remove itself from
the windows taskbar and Windows won't close while the icon is there.
What I did was to process the WM_QUERYENDSESSION message sent to the
main form and set the Active property of the RXLIB tray icon to false
before calling inherited for this message. (This is to ensure the
icon has gone inactive before Delphi's processing of WM_QUERYENDSESSION).
Setting the Active property to false is essentially a call to
this API function inside the RXLIB component
Shell_NotifyIcon(NIM_DELETE, @FIconData);
It removes the icon from the taskbar (see win32.hlp), if your icon
component does not have an active property you will need to open
it up because you can't get at the FIconData structure from outside
the component.
--
Sincerely,
Andreas Kyriacou
----------------
http://www.andrikkos.co.uk (Imagine! Image Viewer)