如何在启动画面的任务栏中不显示图标

How to not show icon in taskbar for splash screen

我正在使用 this question 中的代码在 Delphi 中创建启动画面。

看起来像这样:

begin

  SplashForm := TSplashForm.Create(nil)

  Application.Initialize;

  //create your forms, initialise database connections etc here
  Application.CreateForm(TForm1, Form1);

  if Assigned(SplashForm) then
    SplashForm.OkToClose := True;

  Application.Run;

end.

由于技术原因,我在项目文件中保留了

Application.MainFormOnTaskbar := False;

发生的情况是启动画面的任务栏中显示一个图标,然后随着启动画面关闭,该图标消失,然后该图标重新显示在任务栏中(对于主窗体)。

如何防止启动画面 screen/form 显示时显示图标? (这样图标只会在显示主窗体时显示一次)。

感谢@Sertac 向我指出 this 相关问题。覆盖 CreateParams 对我没有帮助,但是,以下答案有效:

来源:http://www.scalabium.com/faq/dct0096.htm

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE);
  SetWindowLong(Application.Handle, GWL_EXSTYLE,
    GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
  ShowWindow(Application.Handle, SW_SHOW);
end;