Delphi自定义表单图标设置

Delphi自定义表单图标设置

本文介绍了Delphi自定义表单图标设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Delphi学习者。我有一些Delphi项目。在我所有的项目中,除了ApplicationIcon之外,我都使用了单独的FormIcon。 FormIcon具有256X256、48X48、32X32和16X16不同大小的图标。我注意到在WinXP和Win7中, Alt + Tab显示了模糊的FromIcon。在Win7中,任务栏中的FormIcon也变得模糊。我认为这是由于使用16X16大小的Icon创建的尺寸过大。对此没有自动解决方案。我已经在互联网上搜索了,发现我必须打电话

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);

但我不知道何时调用它以及如何调用它?因此,请给出一个完整的教程,以便可以统一实施。我用IconResource找到了一种解决方案并调用它。但我不喜欢这种解决方案。我只想使用FormIcon。 Plaese帮助我。

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.

推荐答案

您需要创建一个图标文件( .ico ),其中有多个尺寸(页面)。最简单的方法是使用图标编辑器,例如,它将为您完成所有工作。 (从现在开始,我将其称为 GFIE 。)

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.)

这些说明特定于GFIE,并且需要能够正确处理多尺寸图标的Windows版本;如果您正在运行Delphi XE2,则可能使用的是它。我在Windows 7 64位系统上测试了使用Delphi 2007创建的图标(出于测试兼容性)。

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.


  • 创建图像想要用作您的图标。最好以最大的分辨率(最好是256 x 256或更高)创建它。您可以使用图标以外的其他格式,例如PNG或BMP。您可以使用GFIE或其他任何图像编辑器来创建它。

  • 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.

如果尚未创建,请在GFIE中打开该图像。从主菜单中选择 Icon->从图像创建Windows图标...

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:


  • 单击确定,GFIE将创建图像文件。将其保存到磁盘,然后像往常一样将其用于表单或应用程序。 (对于您的应用程序,为 Project-> Options-> Application->图标,或使用Object Inspector设置表单的图标。)编译项目。 / li>
  • 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会根据系统上有效的设置自动选择合适的图像大小;如果您尚未创建正确的尺寸,则会选择最接近的匹配并将其调整为正确的尺寸。您可以在Windows资源管理器中对此进行测试:更改为应用程序所在的文件夹,然后使用查看菜单选择小图标中型图标大图标,然后看着您的应用程序图标平滑地更改为适当的分辨率。

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.

这篇关于Delphi自定义表单图标设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 07:09