Reputation: 593
I am a Delphi learner. I have some Delphi projects. In all my projects, I have used seperate FormIcon other than the ApplicationIcon. FormIcon have 256X256, 48X48, 32X32 and 16X16 different sizes of Icons. I hve noticed that in WinXP and Win7 "Alt+Tab" shows a blurred FromIcon. In Win7 FormIcon is also blurred in Taskbar. I think this due to stretched size created using 16X16 size Icon. There is no automatic solution for this. I have googled in internet and I found that I have to call
SmallIconSize := GetSystemMetrics(SM_CXSMICON);
LargeIconSize := GetSystemMetrics(SM_CXICON);
but I am unable to understand when it will be called and how? So please give one complete tutorial so that it can be implemented universely. I hve found one solution with IconResource and calling it. But I don't like this solution. I wish to use the FormIcon only. Plaese help me.
Upvotes: 0
Views: 4843
Reputation: 125669
You need to create a single icon file (.ico
) with multiple sizes (pages) in it. The easiest way to do that is with an icon editor like GreenFish Icon Editor, which will do all the work for you. (I'll refer to it as GFIE
from now on.)
These instructions are specific to GFIE, and require a version of Windows that properly handles multi-sized icons; if you're running Delphi XE2, you're probably using one. I tested the icon I created using Delphi 2007 (for testing compatibility) on Windows 7 64-bit.
Create the image you want to use as your icon. It's best to create it at the largest resolution possible (256 x 256 or greater is best). You can use other formats besides icon, like PNG or BMP. You can use GFIE to create it, or any other image editor.
If it's not already, open the image in GFIE. Choose Icon->Create Windows Icon From Image...
from the main menu.
In the resulting dialog, check the different sizes you want for your icons. Here's the dialog with the default sizes and color depths:
Project->Options->Application->Icon
for your application, or using the Object Inspector to set the icon for the form.) Compile your project.Windows will automatically select the proper image size based on the settings in effect on your system; if you haven't created the proper size, it will choose the closest match and resize it to the correct size. You can test this right in Windows Explorer: change to the folder your app is in, and then use the View
menu to select Small Icons
, Medium Icons
, and Large Icons
, and watch your application icon smoothly change to the proper resolution.
Upvotes: 2