仅使用内置工具在 Delphi XE 中制作组件图标的最佳方法 [英] Best way to make a component icon in Delphi XE using only the built in tools

查看:11
本文介绍了仅使用内置工具在 Delphi XE 中制作组件图标的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi 7中,包含一个图像编辑程序,可以读写.dcr文件,这些文件只是二进制资源文件(.res文件),带有一个不同的扩展名,按照惯例,它表示 .dcr 文件包含已编译资源,该资源具有命名位图资源,其名称与您的组件名称相对应(名为 TMYCOMPONENT 的位图资源用于名为 TMyComponent 的组件).这些位图是用于在 delphi 组件面板上放置图标的图标"的来源,当您在表单或数据模块上放置非可视组件时,它们是从哪里来的.

In Delphi 7, an image editor program is included, which can read and write .dcr files, which are merely binary resource files (.res files) with a different extension, which by convention indicates that the .dcr file contains a compiled resource with named bitmap resources that have names corresponding to your component names (a bitmap resource named TMYCOMPONENT for a component named TMyComponent). These bitmaps are where the "icons" used to put an icon on the delphi component palette, and on your form or data-module when you drop a non-visual component on it, come from.

Delphi XE 快进 10 年,我正在尝试使用位图文件和 RC 文件制作组件图标,并将其构建为 .DCR 文件,作为 Delphi IDE 的一部分.

Fast forward 10 years to Delphi XE, and I am trying to make component icons using a bitmap file, and an RC file, and have that build to a .DCR file, as part of the Delphi IDE.

应该只是在 .dpk(包源)文件中添加一个 .Rc 文件和这样的声明,如下所示:

It should be simply a matter of adding an .Rc file and a declaration like this in the .dpk (package source) file, like this:

{$R mypackageicons.rc mypackageicons.dcr}

包含组件图标的示例 .rc 文件:

A sample .rc file containing a component icon:

 // COMPONENT ICON RESOURCES
 TMYCOMPONENT BMP "TMYCOMPONENT.BMP"

但是我无法让它工作.当我尝试时,您似乎遇到了一些奇怪的 RLINK32 错误,并且 IDE 在 borlandmm.dll 中崩溃:

However I can not get this to work. It seems that you get some bizarre RLINK32 errors, and IDE crashes in borlandmm.dll, when I try it:

[DCC Error] E2161 Error: RLINK32: Unsupported 16bit resource in file "C:	empcompiconCOMPONENTICONS.rc"
[DCC Fatal Error] F2084 Internal Error: AV21515155-W06000D07-1

有问题的位图文件是一个简单的 256 色 bmp 文件,大小为 24x24 像素,我也尝试过 16 色位图,但没有成功.在我看来,ImageEdit 程序是我所知道的唯一可以用来创建 Delphi 组件图标的方法.

The bitmap file in question is a simple 256 color bmp file size 24x24 pixels, and I have also tried 16 color bitmaps, with no luck. It seems to me that the ImageEdit program is the only way that I know of that I can use to create Delphi component icons.

我错过了什么?

更新: 对于无法使用 Delphi 7 图像编辑器的人来说,外部工具是一个不错的解决方案,而且实际上可能更胜一筹,但我更愿意只使用Delphi 附带了什么,因为似乎应该可以只使用一个 {$R} 声明、一个文本文件和一个用画笔制作的 bmp 文件.当然,他们并没有忽略使用这个很棒的 1.5 GB 大开发工具制作组件图标的方法!.. update2: 还有一种方法;Rudy V. 找到了它.

Update: The external tools are a nice solution for people who don't have access to the Delphi 7 image editor, and may in fact be superior, but I would prefer to do this using only what ships with Delp because it seems that it should be possible using just one {$R} declaration, a text file, and a bmp file made with paintbrush. Surely they didn't omit to make a way to make component icons, with this great big 1.5 gigabyte developer tool! .. update2: And there is a way; Rudy V. found it.

推荐答案

我已经使用并取得了巨大的成功:

I have used and had great success with:

我刚刚在 XE 中尝试了以下操作,并且成功了.

I just tried the following, in XE, and was successful.

  • 我在 NewAnimates.pas 中创建了一个新组件 TNewAnimate.
  • 我将 TNewAnimate.pas 添加到 dclusr.dpk.
  • 我使用 Project → 添加了一个位图(称为 TMRUComboBox.bmp,反正我只是有那个)Resources and Images... 对话框添加到 .dpk 并将其命名为 TNEWANIMATE.
  • 我重新安装了 dclusr.dpk.
  • I created a new component, TNewAnimate, in NewAnimates.pas.
  • I added TNewAnimate.pas to dclusr.dpk.
  • I added a bitmap (called TMRUComboBox.bmp, I just had that around anyway) using the Project → Resources and Images... dialog to the .dpk and gave it the name TNEWANIMATE.
  • I re-installed dclusr.dpk.

dclusr.pdk 的源文件有一个新条目 {$R *.dres}(注意扩展名).我可以在 Samples 调色板中看到 TNewAnimate 以及 TMRUComboBox.bmp 中的字形.

The source file for dclusr.pdk got a new entry {$R *.dres} (note the extension). I could see the TNewAnimate in the Samples palette with the glyph in TMRUComboBox.bmp.

我将 dclusr.dres 放在与 dclusr.dpk 相同的目录中(通常在 C:Program Files 下,但不是在我的设置中).我试图用 XN 资源编辑器打开它,但它拒绝打开它并显示一条神秘的错误消息.好像不是普通的.res文件.

I located dclusr.dres in the same directory as dclusr.dpk (which is normally under C:Program Files, but not in my setup). I tried to open it with XN Resource Editor, but that refused to open it with a cryptic error message. It is not a normal .res file, it seems.

这篇关于仅使用内置工具在 Delphi XE 中制作组件图标的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆