0

I am using the code from this question to create a splash screen in Delphi.

It looks something like this:

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.

For technical reasons, in the Project file I keep

Application.MainFormOnTaskbar := False;

What happens is that an icon displays in the Taskbar for the splash screen, then as the splash screen is closed, the icon disappears, and then the icon is reshown in the taskbar (for the main form).

How can I prevent the icon showing while the splash screen/form is showing? (so that the icon will only show once, when the main form is displayed).

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
RaelB
  • 3,301
  • 5
  • 35
  • 55
  • Does your splash form have a title bar? If so, then remove it. Also delay giving your application a title until after the splash screen closes. – Dsm Aug 22 '19 at 15:48
  • No. BorderStyle = bsNone. Actually I do not set the title (i removed that code from the sample), even using Title = '' does not make a difference. – RaelB Aug 22 '19 at 16:11
  • OK. That would have worked in windows 7 - the last time I tried it. Guess it doesn't work in windows 10. – Dsm Aug 22 '19 at 16:15
  • Did you try answers that involve overriding createparams. E.g. like https://stackoverflow.com/questions/261601/hide-a-forms-taskbar-button-without-using-ws-ex-toolwin . – Sertac Akyuz Aug 22 '19 at 16:27
  • Thanks for that reference. overriding CreateParams did not help me, but answer from Scalabium software worked great. – RaelB Aug 22 '19 at 18:34
  • Then this is not a duplicate since that answer does not answer that question. Consider posting an answer. You're welcome. – Sertac Akyuz Aug 22 '19 at 19:08

1 Answers1

1

Thanks to @Sertac for pointing me to this related question. Overriding CreateParams did not help me, however, the following answer worked:

Source: 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;
RaelB
  • 3,301
  • 5
  • 35
  • 55
  • That won't hide the icon only, but maybe you mean the whole task button to begin with, not its icon only. – AmigoJack Aug 23 '19 at 09:14