Delphi XE6 - How to make user defined components image show up on the pallette

◇◆丶佛笑我妖孽 提交于 2019-12-24 02:34:09

问题


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

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.

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.

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.

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.

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

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?


回答1:


I think I found a work around for this problem.

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.

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.

Next, load up image editor and create a new dcr file called 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.

Save the dcr in the same directory as 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, all the correct icons come up.

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



来源:https://stackoverflow.com/questions/23716367/delphi-xe6-how-to-make-user-defined-components-image-show-up-on-the-pallette

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!