Delphi – Hide the Main Form in a Delphi 2009 Application

delphidelphi-2009vcl

The following code works fine in Delphi 7. However, in Delphi 2009 the form does remain hidden but the button on the taskbar is now appearing.

ShowWindow(Handle, SW_HIDE);
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW );
ShowWindow(Handle, SW_SHOW);

The above code is called in the FormCreate method.

Best Answer

Turns out the reason we were seeing the Application window on the taskbar was a simple setting similar to stukelly's answer but not quite.

To get the main form to appear on the task bar and hide the application menu you apply:

Application.MainFormOnTaskbar := True;
Application.ShowMainForm := False;

No code behind the form create or anything required.

Related Topic