0

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.

Kenneth Cochran
  • 11,954
  • 3
  • 52
  • 117
Rubi Halder
  • 583
  • 3
  • 12
  • 24
  • The solution involving using form icon, is the solution that you're already using. And you don't like it because of its defective behavior, so you have to use something else. Possible duplicates: [Delphi form icons are blurry on Windows 7's taskbar (with MainFormOnTaskbar enabled)](http://stackoverflow.com/q/2621814/243614),   [Blurred Delphi Form Icon in Windows 7 Taskbar](http://stackoverflow.com/q/8767191/243614). – Sertac Akyuz Aug 08 '12 at 21:40
  • It looks like the second question in the previous comment is in fact one of yours (with a different account). That question also has the other one linked to itself. So the links are probably useless.. – Sertac Akyuz Aug 08 '12 at 21:45
  • @Sertac Ya, this one seemed familiar! – David Heffernan Aug 08 '12 at 21:54
  • @Sertac: This question is my fault. In one of the prior questions, David made a comment about using `GetSystemMetrics`, and the poster asked in a comment response how to do so. I informed Rubi that it should be a new question, and this one was posted (which in part was why I answered as I did - it was my advice that resulted in the question, although I'm getting really irritated at all of the "please provide a complete, full application" request in every question Rubi asks). – Ken White Aug 09 '12 at 00:25
  • @Ken - I found and read the question you mention, AFAICT the comment you mention is about finding the correct icon size to use in system tray. This question does not ask how to find the system icon size or how to use GetSystemMetrics. You cannot possibly be blamed that the poster instead asks the ultimate form icon solution again. :) – Sertac Akyuz Aug 09 '12 at 14:27

1 Answers1

2

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:

enter image description here

  • Click OK, and GFIE will create the image file. Save it to disk, and then use it for the form or your application as usual. (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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Thanks. What you have told, I have already done with "Axialis IconWorkshop". There is no problem for application Icon. It is for the FormIcon only. I have done upto my label best. I am not a liar. I am really facing problems for all my projects and I don't have so much money to recruit someone for writing codes for me. So I don't have other option. Please download [**My Project**](http://netload.in/dateiIk39kq8LXf/KoushikHalder'sTimerEffect.7z.htm) and see what I am telling. I don't like to tell someone to waste their valuable time for me. If you think to help me, then only help me. – Rubi Halder Aug 09 '12 at 07:02
  • The form icon works **exactly** the same way, except it gets set in the Object Inspector. I think your confusion is that Windows doesn't change icons the way you think it does for forms. Regardless, I don't have time to download everyone's projects and work on them for free, and neither does anyone else here. As I said before, we're here to **help**, not do everything for you. If you need the projects done, you're going to have to work on them yourself. Good luck. – Ken White Aug 09 '12 at 10:57
  • In my case I have 6 possible icon sizes from 16x16 to 256x256. Application chooses the smallest one which is blurred. :-( – truthseeker May 07 '14 at 06:08