Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 214
delphirules Avatar asked Dec 29 '20 18:12

delphirules


People also ask

How to change the default application icon in Delphi?

Delphi has no control over it. Windows simply selects "the first icon" as the default application icon.

How to use high resolution image as component icon in Delphi?

Here is the link to high resolution image of the bike that I want to use as a icon for my component. 1) Save the image as a bitmap file, but the file is huge – 40 MB and 4819×2968 pixels. That’s OK! 2) Create a new Delphi package project. To keep the steps simple let’s stick with just one “designtime and runtime” package.

What is the default icon to use as the application icon?

The default icon to use as the application icon is determined by Windows. Delphi has no control over it. Windows simply selects "the first icon" as the default application icon.

How to add a sample image to a Delphi app?

7) Create a new visual Delphi app. In the Tool Palette you should find new “Samples” category with a new component with custom image. It seems to be a not very documented, but I hope that this approach is OK to use and that you will find it useful!


1 Answers

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.
like image 137
Andreas Rejbrand Avatar answered Oct 13 '22 22:10

Andreas Rejbrand