I tried your procedure for placing my application on the system tray and it works fine. My problem is that it opens the form1 when the application is executed, but I do not want to open it until the user clicks on the menu item on the right-click menu of the system tray icon.
Any help will be greatly welcome.
The easiest way to have the form not show up is to do the following:
1) Define a Boolean variable in the private section of your form’s type declaration ?let’s call it FrmCreate.
2) In the Form’s OnCreate, set FrmCreate to True.
3) Next, drop a TTimer on the form and in its OnTimer event, write the following:
procedure TMainForm.Timer1Timer(Sender: TObject);begin if FrmCreate then begin ShowWindow(MainForm.Handle, SW_HIDE); Timer1.Enabled := False; end;end;
The timer is only active at create time so you can just hide the window as soon as it pops up. This will probably cause a bit of a flash, but that’s usually not a big deal.