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

问题描述

在Delphi 7中,包含一个图像编辑器程序,可以读取和写入 .dcr 文件,这只是二进制资源文件()。具有不同扩展名的res 文件),这通常表示.dcr文件包含具有命名位图资源的已编译资源,该资源具有与您的组件名称相对应的名称(名为TMYCOMPONENT的名称为TMyComponent)。这些位图是图标用于在delphi组件调色板上放置图标的位置,以及在其上放置非可视组件的表单或数据模块时,来自。



快速前进到Delphi XE十年,我正在使用位图文件和RC文件制作组件图标,并将其构建为.DCR文件,作为Delphi IDE的一部分。 / p>

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

  {$ R mypackageicons.rc mypackageicons.dcr} 

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

  //组件图标资源
TMYCOMPONENT BMPTMYCOMPONENT.BMP

但是我不能让这个工作。看来你会发现一些奇怪的RLINK32错误,并且IDE崩溃在borlandmm.dll,当我尝试它:

  [DCC错误] E2161错误:RLINK32:文件C:\temp\compicon\COMPONENTICONS.rc中不支持的16位资源
[DCC致命错误] F2084内部错误:AV21515155-W06000D07-1

所讨论的位图文件是一个简单的256色bmp文件,大小为24x24像素,我也尝试了16个颜色位图,没有运气。在我看来,ImageEdit程序是我知道可以用来创建Delphi组件图标的唯一方法。



我错过了什么?



更新:外部工具对于无法访问Delphi 7图像编辑器的人来说是一个很好的解决方案,实际上是优越的,但我宁愿只使用Delphi附带的东西,因为似乎应该只能使用一个{$ R}声明,一个文本文件和一个用画笔制作的bmp文件。当然,他们并没有忽略制作组件图标的方式,这个伟大的1.5千兆字节的开发者工具! .. update2:有一种方法; Rudy V.发现它。

解决方案

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




  • Colin Wilson的

  • 安德斯·梅兰德的



更新



我刚刚在XE中尝试过以下内容,并获得了成功。




  • 我在NewAnimates.pas 中创建了一个新组件 TNewAnimate / li>
  • 我将TNewAnimate.pas 添加到了dclusr.dpk 。

  • 我添加了一个位图(称为 TMRUComboBox.bmp ,我只是在那里)使用 Project->资源和图像... 对话框到 .dpk ,并给它名称​​ TNEWANIMATE

  • 我重新安装了dclusr.dpk 。



dclusr.pdk 的源文件获得了新的条目 {$ R * .dres} (注意扩展名)。我可以在样本调色板中看到 TNewAnimate ,其中包含TMRUComboBox.bmp 中的字形。



我将 dclusr.dres 放在与 dclusr.dpk 相同的目录中(通常位于C:\Program Files 下,但是不在我的设置)。我试图用XN资源编辑器打开它,但是拒绝用隐藏的错误消息打开它。它不是一个正常的 .res 文件。




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.

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.

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}

A sample .rc file containing a component icon:

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

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:\temp\compicon\COMPONENTICONS.rc"
[DCC Fatal Error] F2084 Internal Error: AV21515155-W06000D07-1

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.

What am I missing out on?

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 Delphi, 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:

Update

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

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

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.

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中使用内置工具制作组件图标的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 18:58