I've been doing some tests and searching too. I've been pinning to the taskbar and unpinning to simulate the problem. I don't have a solution at this time. I believe this is a Windows problem. I don't think I can fix the problem in code. You may be wondering why other apps such as Sentinel when pinned to the taskbar, the icon looks normal and that's because the icon is set at the application level. In ProScan, the default icon is set at the application level but for changing it dynamically when there's scanner activity, the icon needs to be set at the form level and when the form icon changes, the form title/caption area changes and that will make the taskbar icon change too..
I made a test app in c# targeting the .NET 9.0. That way the .NET Framework is out of the picture. Here's a snippet of the code to set the form icon. I think setting the form icon is the only way to change the icon dynamically in the taskbar.
{edit} I was searching for 'api to set the taskbar icons' w/ no relevant results.
I made a test app in c# targeting the .NET 9.0. That way the .NET Framework is out of the picture. Here's a snippet of the code to set the form icon. I think setting the form icon is the only way to change the icon dynamically in the taskbar.
{edit} I was searching for 'api to set the taskbar icons' w/ no relevant results.
C#:
private void button1_Click(object sender, EventArgs e)
{
activity= !activity;
if (activity == false)
{
this.Icon = normalIcon;
}
else
{
this.Icon = activityIcon;
// same result as above which is the taskbar icon will not work after the app has been pinned and unpinned
// SendMessage(this.Handle, WM_SETICON, ICON_SMALL, activityIcon.Handle);
}
}
Last edited: