Delphi program in windows 11 shows default icon on task bar instead of runtime assigned icon

94 views Asked by At

I want my program (developed with Delphi 10.3) to show a different taskbar icon depending on the database it is working on.

I use this code in my OnCreate handler (the DBCompany and CompanyIconFile variables are loaded from an INI file):

procedure TFrmMain.FormCreate(Sender: TObject);
var
  IcoFile: string;
begin
  Application.Title := DBCompany + ' ' + Application.Title;
  IcoFile := CompanyIconFile;
  if FileExists(IcoFile) then
  begin
    Application.Icon.LoadFromFile(IcoFile);
    Self.Icon.LoadFromFile(IcoFile);
  end;
end;

This works as it should on Windows 7, Windows 8, Windows 10: the taskbar shows the company's icon.

On Win 11, it doesn't work. Instead, the Win 11 taskbar always shows the icon that I assigned to the application in the Delphi project options.

I restarted the Win 11 computer, so it could not be the icon cache (?).

0

There are 0 answers