0

I have a button which runs a job, let's replace the job with just a 'Sleep' for a few seconds. When clicking the button, the form's icon changes:

private void ButtonStartClick(object sender, EventArgs e)
    {
        this.Icon = Properties.Resources.RED_32x32_ICON;

        System.Threading.Thread.Sleep(4000);

        this.Icon = Properties.Resources.GRE_32x32_ICON;
    }

This successfully changes the icon for the 'Form' that the button is on - but it's NOT changing the taskbar icon?!

I'm fairly sure I had something similar running in VB last year whereby changing the currently visible form icon would change the taskbar icon too. This was great for showing when my app was "busy"

I tried changing the default icon for my app and inheriting it, and also just applying my icon at form load...

private void MainForm_Load(object sender, EventArgs e)
    {
        // this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
        // this.Icon = Properties.Resources.GRE_32x32_ICON;
    }

There are a few related hits when googling this but mainly to do with just changing the icon via the app settings and not during run time?!

jamheadart
  • 5,047
  • 4
  • 32
  • 63
  • Maybe this can help: https://stackoverflow.com/questions/43179090/change-taskbar-icon-at-runtime-on-deployed-app – Lucian Sep 11 '18 at 08:05
  • This has *nothing* to do with VB. All Windows applications work the same. Perhaps the VB application run on an older Windows version? – Panagiotis Kanavos Sep 11 '18 at 08:06
  • @Lucian that link doesn't help at all. The answers are unrelated to the question, which is why they were downvoted – Panagiotis Kanavos Sep 11 '18 at 08:07
  • 1
    Project > Properties > Application tab, Icon setting. That is the icon that is displayed on the task bar, determined at build-time. Changing it has a sharp edge as well when the OS has seen your program run with another one, google "windows reset shell icon cache". – Hans Passant Sep 11 '18 at 08:09
  • 1
    In pre-Windows 7 versions the taskbar displayed only the active forms. The taskbar icon was nothing more than the form's icon. Changing the form's icon did change the taskbar. In Windows 7 and later the taskbar displays a lot more and can contain pinned applications with jumplists, recent documents etc. The icon can be used to display progress, status, jump lists. This requires a different set of APIs. The default icon for a pinned icon is the *shortcut's* icon, not the form's. – Panagiotis Kanavos Sep 11 '18 at 08:10
  • OK, so the great stuff at http://blogs.microsoft.co.il/sasha/2009/02/16/windows-7-taskbar-overlay-icons-and-progress-bars/ looks like what I need but I have no idea how to import that functional library to use the 'SetTaskbarOverlayIcon' - I'll leave it for now :/ thanks! – jamheadart Sep 11 '18 at 08:18

0 Answers0