There is a program on Delphi XE. At startup, the program is minimized to tray (using the built-in component TrayIcon). How to make the program intercept these events on and off when shutting down Windows or logging out? If possible, code samples are needed.
PS: I bring the folding code to tray when the program starts:
DM.TrayIcon1.Visible := True; DM.TrayIcon1.Hint := 'Журнал заявок'; // Убираем с панели задач ShowWindow(Handle, SW_HIDE); // Скрываем программу ShowWindow(Application.Handle, SW_HIDE); // Скрываем кнопку с TaskBar'а SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or (not WS_EX_APPWINDOW));