简体   繁体   English

如何为FireMonkey组件添加设计时图标?

[英]How to add design time icon for FireMonkey component?

I have read this article by Paweł Głowacki and I have been able to display an icon for my component. 我已经阅读了PawełGłowacki的这篇文章,我已经能够为我的组件显示一个图标。 The result is the following: 结果如下:

在此输入图像描述

I can see the image in the Tool Palette and in the structure view. 我可以在工具选项板和结构视图中看到图像。 By the way in the designer I see the default icon: 顺便说一下,在设计器中我看到了默认图标:

在此输入图像描述

How can I display the icon of my component in the designer as well? 如何在设计器中显示组件的图标?


I am using Delphi Tokyo 10.2 Update 2. I have followed the article I have linked to get the image shown. 我正在使用Delphi Tokyo 10.2 Update 2.我已经按照我链接的文章来显示图像。 My component is the following: 我的组件如下:

type
  TEquationSolver = class(TComponent)
    //code...
  end;

Basically, I have done the following: 基本上,我做了以下事情:

  1. I have created 3 bitmaps (16x16 24x24 32x32) and a png (128x128) 我创建了3个位图(16x16 24x24 32x32)和一个png(128x128)
  2. I have added them as resources going into Project > Resources and Images 我已将它们作为资源添加到Project> Resources and Images中 在此输入图像描述
  3. I have called them TEquationSolver with the suffix that indicates the size. 我称它们为TEquationSolver ,后缀表示大小。 In this way they are properly displayed on the IDE. 通过这种方式,它们可以正确显示在IDE上。

What am I missing for the design time part? 我在设计时间部分缺少什么? In this article I have read the following: 文章中,我已经阅读以下内容:

Our guide is: Use PNG if you want very easy backwards compatibility, or small file (BPL) size; 我们的指南是:如果您想要非常简单的向后兼容性或小文件(BPL)大小,请使用PNG; use bitmaps if you want fast loading. 如果要快速加载,请使用位图。 We use bitmaps for 16, 24, and 32px icons, and PNG for the 128px icons. 我们使用位图为16,24和32px图标,PNG用于128px图标。

In fact I have 16x16, 24x24, 32x32 bitmaps and the 128px png. 实际上我有16x16,24x24,32x32位图和128px png。 Is there something else? 还有别的吗?

It seems that you have to create the files I have shown above plus the image for the Designer. 您似乎必须创建我上面显示的文件以及 Designer的图像。 The latter needs to match the name of the class that inherits from TComponent (in my case): 后者需要匹配从TComponent继承的类的名称(在我的例子中):

在此输入图像描述

As you can see I have added another bitmap (it's the 32x32, I have just made a copy and changed the name) and I have used TEquationSolver as name. 正如您所看到的,我添加了另一个位图(它是32x32,我刚刚制作了一个副本并更改了名称)并且我使用了TEquationSolver作为名称。 After a Build + Install I have the following result: 构建+安装后,我得到以下结果:

在此输入图像描述


Note that I could have added only logo.bmp as resource (with the ID that matches the TComponent-derived class name) and it would have worked anyway. 请注意,我本可以添加logo.bmp作为资源(使用与TComponent派生类名称匹配的ID),它仍然可以工作。 The problem is that the pictures won't be neat because they'll be resized and they may appear blurred, like in my case. 问题是图片不会整洁,因为它们会被调整大小并且它们可能看起来很模糊,就像我的情况一样。

For this reason I think that it's good: 出于这个原因,我认为这很好:

  1. Put an image that will appear in the form designer 放置将出现在表单设计器中的图像
  2. Put the 16x16, 24x24, 32x32 and 128x128 that will be used by the IDE 放置将由IDE使用的16x16,24x24,32x32和128x128

The difference is evident in my case. 在我的情况下,差异很明显。 When I have only a single bitmap the quality of the image is low but when I provide the various sizes they look better. 当我只有一个位图时,图像的质量很低,但是当我提供各种尺寸时,它们看起来更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM