Delphi XE6 - 如何使用户定义的组件图像显示在调色板上 [英] Delphi XE6 - How to make user defined components image show up on the pallette

查看:191
本文介绍了Delphi XE6 - 如何使用户定义的组件图像显示在调色板上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从2007迁移到XE6,并且有自己和第三方编写的几个用户定义的组件。

I am migrating from 2007 to XE6 and have several user defined components written by both myself and third party.

在delphi 2007中安装组件时,只需添加组件到库中它会自动找到并将同名的DCR加载到dpk文件中并将图像加载到调色板上。

When installing components in delphi 2007 you just add the components to the library and it automatically found and loaded the DCR of the same name into the dpk file and it loaded the image onto the pallette.

在delphi中XE6不会自动生成加载图像文件,而不是只获得一个默认图像,对于每个用户定义的组件都是相同的。

In delphi XE6 is does not automatically load the image files, instead you just get a default image which is the same for every user defined component.

我寻找并找到了关于此主题的一些主题,描述了手动添加DCR文件到我已经完成的项目源中但是它不起作用和/或它不可靠。

I sought and found some topics on this subject which described manually adding the DCR files into the project source which I have done but it does not work and/or it is unreliable.

首先当我重新安装bpl时,样本调色板(其中)我已经加载了我的所有组件)删除我刚安装的所有组件并且什么也没显示。

Firstly when I reinstall the bpl, the samples pallette (which I have loaded all my components into) deletes all the components I have just installed and shows nothing.

当我关闭Delphi并重新启动时,组件出现在托盘上但是randoml y某些图像仍然是默认图像。

When I shut down Delphi and restart, the components appear on the pallete but randomly some of the images are still the default images.

每次重新插入bpl时,每次不同的图像都有正确的图像时,我会得到不同的结果其他人有默认图像。看起来非常随机,哪些不会出现。

I get a different result, every time I re-intall the bpl, each time different images have the correct image and others have the default image. It appears quite random which ones don't appear.

有什么线索发生了什么?

Any clues what is going on?

推荐答案

我想我找到了解决这个问题的方法。

I think I found a work around for this problem.

我注意到我加载了SynEdit并且它没有任何问题它在调色板上的图标,所以我加载了dpk以查看它是如何做到的。

I noticed that I have SynEdit loaded and it does not have any problem with putting its Icons on the palette, so I loaded up the dpk to see how it did it.

当每个组件作为单独的文件添加时,似乎存在问题库。

It seems that the problem exists when each component is added as a seperate file to the library.

关键是只生成一个文件,例如MyLibReg.pas,并将每个组件文件添加到设备的Uses部分。创建注册过程,然后在注册过程中一次性注册所有组件。您必须浏览每个文件,找到单独的注册程序,将类名复制并粘贴到MyLibReg.pas的注册程序中,然后在那些文件中删除那些程序。

The key is to make just one file eg MyLibReg.pas and add each component file into the "Uses" section of the unit. Create the Register procedure and then register all the components in one go in the Register procedure. You will have to go through each file, find the individual register procedures, copy and paste the class names into MyLibReg.pas's register procedure then REM out those procedures in those files.

接下来,加载图像编辑器并创建一个名为MyLibReg.dcr的新dcr文件。

Next, load up image editor and create a new dcr file called MyLibReg.dcr.

下一位有点乏味,加载所有的dcr文件将用户组件放入图像编辑器并将图像复制并粘贴到MyLibReg.dcr中,您需要手动创建所有位图名称,然后粘贴图像。

The next bit is a bit tedious, load up all the dcr files from all your user components into image editor and copy and paste the images into MyLibReg.dcr, you will need to create all the bitmap names manually then paste the images in.

保存dcr在与MyLibReg.pas相同的目录中。

Save the dcr in the same directory as MyLibReg.pas.

在XE6中选择组件/安装组件,选择安装到新软件包。以单位文件名
导航到MyLibReg.Pas并继续并构建/安装包。

In XE6 select Component/Install Component, Select "Install Into new package". in unit filename navigate to MyLibReg.Pas and continue and build/install the package.

Voila,所有正确的图标出现。

Voila, all the correct icons come up.

似乎XE6只能可靠地使用每个bpl的一个dcr文件。

It seems XE6 can only reliably work with one dcr file per bpl.

这篇关于Delphi XE6 - 如何使用户定义的组件图像显示在调色板上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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