Mega Code Archive
How can I have an animated icon (when the form is minimized)
Title: How can I have an animated icon (when the form is minimized) ?
Question: How can I have an animated icon (when the form is minimized) ?
Answer:
It uses one ImageList to hold the icons to be used. The icons are changed from a timer.
{CurrentState is a byte that knows which icon is currently displayed. It is initialized in the form's OnCreate() method.}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if IsIconic(Application.Handle) then
begin
ImageList1.GetIcon(CurrentState, Application.Icon);
InvalidateRect(Application.Handle, nil, True); {This is critical!}
inc(CurrentState);
if CurrentState ImageList1.Count then
CurrentState := 1;
end;
end;