0

Using Delphi 10 Seattle Update 1.

I want to create an instance of TTaskBar at runtime in a VCL application. I found an interesting problem with TTaskBar:

var F: TForm;
    B: TTaskBar;
begin
  F := TForm.Create(Application);

  B := TTaskBar.Create(F);
  B.TabProperties := [TThumbTabProperty.CustomizedPreview];

  F.Show;
end;

The above code will raise an error: Could not register tab. Error 0.

But, this code works:

var F: TForm;
    B: TTaskBar;
begin
  F := TForm.Create(Application);
  F.Show;

  B := TTaskBar.Create(F);
  B.TabProperties := [TThumbTabProperty.CustomizedPreview];
end;

It seems that creating a TTaskBar instance for a hidden form is not allowed.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Chau Chee Yang
  • 18,422
  • 16
  • 68
  • 132
  • You did not say which version of Delphi you are using, but `TTaskBar` has had a lot of bugs over the years, and not all of them are fixed still, so you are best off simply not using it *AT ALL*. Use Microsoft's `ITaskbarList...` COM interfaces directly instead. – Remy Lebeau Dec 23 '15 at 03:10
  • @RemyLebeau: In `Delphi 10 Seattle Update 1`. Subject has updated. Thanks – Chau Chee Yang Dec 23 '15 at 03:13
  • 3
    As for the actual error, no you cannot register a tab for a hidden window. In fact, the `ITakbarList3` documentation specifically states that you have to wait until the window's taskbar button has been created before you can perform any `ITaskbarList3`-related operations, and that creation does not happen until the window is shown. – Remy Lebeau Dec 23 '15 at 03:14
  • And also, even if the registration did succeed, one of `TTaskBar`'s bugs is that once it has been registered, updates made to the tab will throw that error even though the registration is still valid. – Remy Lebeau Dec 23 '15 at 03:22

0 Answers0