If you change the FormStyle property of the parent
form. StTrayIcon no longer gets messages and will not
capture the minimize and close messages. This is
caused because the FormStyle destroys and recreates
the from handle which StTrayIcon used to hook into.
To fix this, I modified that HookForm procedure so that
if called with false, it will alway unhook itself correctly.
(this seems to be another bug). I then modified the
DeleteFromTray procedure to call HookForm(false).
Before changing the form's FormStyle property, I set the
trayIcon actvie to false and then set back to true after
the formstyle change. This correctly calls the needed
procedures to re-hook the tray icon.
I have attached a file with the fixed procedures
Bill
Updated Procedures text file