Recent

Author Topic: [SOLVED] Form has no Taskbar entry (because Main-Form invisible?)  (Read 630 times)

Hartmut

  • Hero Member
  • *****
  • Posts: 1094
I have 2 GUI-programs, which technically "have" a Main-Form, but this is never displayed, because each program only calls a (different) procedure of a common Unit, which creates a dynamic Form, which then does everything what is needed. The problem is: both programs show no Taskbar entry. But I want to have a Taskbar entry, e.g. if this program is hidden by other programs to quickly show it again etc.

Details:
 - The Main-Forms of both programs are standard 'Form1's, created "as normal" and hidden via 'Visible:=false' in FormShow() respective FormActivate(), where one of above procedures of a common Unit is called.
 - The dynamic Forms are created by CreateNew(Application) and have BorderStyle=bsSizeable, because they shall be resizeable.
 - Only if I minimize the dynamic Form, than a Taskbar entry for that program appears (and stays permanent).

I have this behaviour in Win7 and Win10, but not on Linux (Ubuntu, GTK2), where I have always normal Taskbar entries for both programs.

Does somebody know, how to enable this Taskbar entries on Win7/Win10/Win11?
Thanks in advance.
« Last Edit: February 18, 2026, 11:52:58 am by Hartmut »

n7800

  • Hero Member
  • *****
  • Posts: 639
  • Lazarus IDE contributor
    • GitLab profile
Re: Form has no Taskbar entry (because Main-Form invisible?)
« Reply #1 on: February 17, 2026, 06:23:10 pm »
I thought you might find the comment from the "adjacent" thread interesting, as well as the comment below about "ShowInTaskBar".

But please note that there is a bug that might be relevant to your situation. I don't know the details, but I hope someone can help you.

LV

  • Sr. Member
  • ****
  • Posts: 426
Re: Form has no Taskbar entry (because Main-Form invisible?)
« Reply #2 on: February 17, 2026, 06:53:35 pm »
The first thought that comes to mind is
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Top := -1000;
  4. end;
  5.  
And what OP described should work.
P.S. Instead of
and hidden via 'Visible:=false' in FormShow() respective FormActivate()
« Last Edit: February 17, 2026, 07:05:38 pm by LV »

Hartmut

  • Hero Member
  • *****
  • Posts: 1094
Re: Form has no Taskbar entry (because Main-Form invisible?)
« Reply #3 on: February 17, 2026, 07:32:47 pm »
Thanks a lot n7800 for your reply. A quick test on Win7 gave:
 - Application.MainFormOnTaskBar:=true; => shows no Taskbar entry, even after minimizing the Form (worse that before)
 - FD.ShowInTaskBar:=stDefault; => same as without this command ('FD' is the dynamic Form)
 - FD.ShowInTaskBar:=stAlways; => shows Taskbar entry at program start, but minimizing the Forms shows a second Taskbar entry (for 1 program with no visible Forms)
 - FD.ShowInTaskBar:=stNever; => shows Taskbar entry at program start and everything seems to be correct!
I'm surprised that 'stNever' enables the Taskbar entry... Does someone know why?
Will test tomorrow more detailed and then repeat on Win10.



Thanks LV too. Will test your suggestion tomorrow and report then. Must stop for today.

n7800

  • Hero Member
  • *****
  • Posts: 639
  • Lazarus IDE contributor
    • GitLab profile
Re: Form has no Taskbar entry (because Main-Form invisible?)
« Reply #4 on: February 17, 2026, 07:48:59 pm »
- FD.ShowInTaskBar:=stDefault; => same as without this command ('FD' is the dynamic Form)
 - FD.ShowInTaskBar:=stAlways; => shows Taskbar entry at program start, but minimizing the Forms shows a second Taskbar entry (for 1 program with no visible Forms)
 - FD.ShowInTaskBar:=stNever; => shows Taskbar entry at program start and everything seems to be correct!
I'm surprised that 'stNever' enables the Taskbar entry... Does someone know why?

Just to be clear, are these 3 check options with the "Application.MainFormOnTaskBar" property enabled or disabled? I don't know this code very well, but if I remember correctly, they can interact, so it's worth checking all (6) combinations.

Hartmut

  • Hero Member
  • *****
  • Posts: 1094
Re: Form has no Taskbar entry (because Main-Form invisible?)
« Reply #5 on: February 18, 2026, 11:52:24 am »
I have good news: the problem is solved!

Just to be clear, are these 3 check options with the "Application.MainFormOnTaskBar" property enabled or disabled? I don't know this code very well, but if I remember correctly, they can interact, so it's worth checking all (6) combinations.
I tested the 3 options for 'ShowInTaskBar' without changing Application.MainFormOnTaskBar at this time.

Meanwhile I tested 'FD.ShowInTaskBar:=stNever' more detailed in both programs and also on Win10 and it does exactly what I wanted.
Question:
Still I'm surprised that 'stNever' enables the Taskbar entry... Does someone know why?



Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Top := -1000;
  4. end;
  5.  
This works too! I had thought, that such "illegal" values would be "corrected" internally e.g. to zero, but I was wrong, it works (Win7 + Win10).



And at last I found a 3rd option to solve the problem: I had written, that in 1 program the Main-Form is hidden via 'Visible:=false' in FormShow() and that there a procedure of a common Unit is called, which then acts as the "whole program". Now I found out, that this 'Visible:=false' - which causes the problem - is not neccessary at all, because at this time - the common procedure is called inside of FormShow() - the Main-Form is anyway not yet displayed (which I was not so aware clearly, when I had added the 'Visible:=false').

So FormShow() of the Main-Form now looks like:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormShow(Sender: TObject);
  2.    begin
  3. // Visible:=false; {causes problems and is NOT neccessary}
  4.    PictureViewer(mode,filespec,true); {acts as the "whole program"}
  5.    Visible:=false; {prevents some flicker at program end}
  6.    Close;
  7.    end;
I can use this solution only in 1 program, because the other one uses the INI-file of the Main-Form, which has not yet loaded in FormShow(), so in this 2nd program my "procedure in a common unit" is called later inside of FormActivate().

All tests done with Lzarus 3.6.0 / FPC 3.2.2.

Thanks a lot to n7800 and LV for your great solutions.

 

TinyPortal © 2005-2018