0

I have a tray application that monitors a Windows service. Depending on the status of the Windows Service, I change the application icon to either a green, orange or red LED.

My default application icon is the red LED (Project -> Options -> Application -> Icons).

All the icons change except the icon of the main form, that does not change. The following icons does change:

  1. Tray icon enter image description here
  2. Taskbar icon when maximized enter image description here
  3. Icons of all other forms enter image description here

What do I need to do to get the main form icon to change?

I have even explicitly change the frmMain.Icon but that also did not work.

My code is simple and looks like this:

    {set the application icon}
    if FAppStatus = Error then
      ImageList.GetIcon(2, Application.Icon)
    else
    if FAppStatus = Warning then
      ImageList.GetIcon(1, Application.Icon)
    else
      ImageList.GetIcon(0, Application.Icon);
    frmMain.Icon := Application.Icon;

I have tried different BorderStyles but that made no difference. I also played with Application.MainFormOnTaskbar without success.

Moderator: Please note that this question is NOT about the taskbar icon.

Johan
  • 317
  • 3
  • 11
  • I cannot reproduce your issue. You would have to provide [mcve] – Dalija Prasnikar Feb 18 '22 at 09:34
  • @DalijaPrasnikar - hmmmm, I wrote a little app to demonstrate my problem and I couldn't reproduce it either. That made me think... I took out the TStyleManager and everything worked like it should. – Johan Feb 18 '22 at 11:09
  • Answer: I use a TStyleManager and was setting it in the project source (.dpr) before I create my main form. I moved it to AFTER creating the main form and now my program works fine. – Johan Feb 18 '22 at 11:17

0 Answers0