delphirules
delphirules

Reputation: 7390

Dynamically insert number on Delphi app's icon

I'm on Delphi 10.4.

I'm looking for a way to dynamically insert a number on the app's icon on the taskbar, so the user can know about how many tasks the apps has done so far. This would be dynamically, as soon as the app does a new task, it will increase the icon's number.

Something like the image below.

Is this possible ?

I don't have any code to post here because i don't have any idea how to do this.

enter image description here

Upvotes: 6

Views: 573

Answers (1)

Andreas Rejbrand
Andreas Rejbrand

Reputation: 108948

You might not be aware of the TTaskbar taskbar-configuration component and its OverlayIcon property.

Example:

Screen recording of an app with taskbar icon overlays.

with a very straightforward implementation:

procedure TForm1.btnInfoClick(Sender: TObject);
var
  io: TIcon;
begin
  io := TIcon.Create;
  try
    io.Handle := LoadIcon(0, IDI_INFORMATION);
    Taskbar1.OverlayIcon := io
  finally
    io.Free;
  end;
end;

In your case, you can either create icons 1.png, 2.png, ... non-programmatically and use those, or you can create icons programmatically (create a CreateOverlayIcon(ANumber: Integer): TIcon function).

I should warn you, however, that the TTaskbar component used to be (very) buggy. Therefore I would not use that one; instead, I would use the ITaskbarList3::SetOverlayIcon API directly.

In any case, my suggestion is to split your problem into two parts:

  1. Create overlay icons.
  2. Use the Windows 7 taskbar overlay icon feature to display these on top of your original icon.

Upvotes: 11

Related Questions