views:

777

answers:

2

We have a Windows desktop application written in Delphi that works fine on Windows 7, except that the icon of the main form looks blurry in Windows' new taskbar. As long as the application has not been started the icon looks fine (i.e. when it's pinned to the taskbar). Once it has been started Windows uses the icon of the main form (instead of the .exe resource icon) and it's blurry (it looks like a 16x16 version of the icon is scaled up).

The icon that we use for the .exe and for the main form are exactly the same and it contains all kinds of resolutions, including 48x48 with alpha blending.

My theory is that Delphi ignores/deletes the extra resolutions of the icon when I import the .ico file for the main form in Delphi. Is there a way to prevent/fix this? What's the best way to ensure that an application written in Delphi uses the correct icon resolution in Windows 7's taskbar?

+4  A: 

It can be a bit of a nightmare getting this right. I have found that the most successful strategy is to place a very simple icon on the main form and application, and then to incorporate the ReplaceVistaIcon program into the build workflow to replace the icon with your multiple-icon file after the build is complete (and before signing the exe). This seems to place the icon correctly so that Windows picks it up in preference to any other icon resource. It's a nuisance to have to do this, but once set up (in our FinalBuilder project) it works for us.

The annoying problem, while you are testing this, is that you may have to delete the Windows icon cache to see the effect of any changes. This involves shutting down Explorer to allow you to delete the cache file from a command session.

frogb
+1 Thanks or the suggestion, we would have used this if Sertac's method didn't work so well.
Dennis G.
+3  A: 
Sertac Akyuz
Interesting, as the solution I found was to just not set an icon for the form, and it seemed to work much better using the Application's icon. I will check how it is in Win 7 now.
mj2008
@mj2008 - your solution works fine with W7 too. I overlooked that Dennis mentioned he assigned the same icon for both the application and the form. In that case that would be the simpler solution. My workaround makes sense only if there's a need to assign a different icon to a form.
Sertac Akyuz
The SetFormIcons method worked great in our case, thanks!
Dennis G.