Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Optimization
Expertise: Beginner
Aug 26, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Don't Show Form at Startup of System Tray App

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);
  if FrmCreate then begin
    ShowWindow(MainForm.Handle, SW_HIDE);
    Timer1.Enabled := False;
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.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date