Animate application icon (on taskbar and apllication window)

This trick is pretty simple. You just need few icons (at least two) for animation and Timer component. The rest is easy…

Place two or more Image components on application main form. If you want to make more complex animation with plenty of icons, it’s better to use ImageList component. Then load images into Image components (or ImageList).

The second component is Timer. Put it on your form, set appropriate interval (to make animation smooth) and activate it. In OnTimer event, you need to change application icon to next one from your ImageList (or icon from next Image component). Variable Icon is needed to store actual icon. Make it global and initialize it in OnCreate event of main form. Code below shows an easiest example with just two icons.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Icon1:Boolean;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Icon1=false then
  begin
    Application.icon:=Image1.Picture.Icon;
    Icon1:=true;
  end
else
  begin
    Application.icon:=Image2.Picture.Icon;
    Icon1:=false;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Icon1:=true;
end;

end.