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:
I just tried the following, in XE, and was successful.
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.
Try Resource Editor. A nice replacement for old Image Editor.
First add 'mypackageicons.rc' file to the project, this produces 'mypackageicons.res' at compile time (see related SO answer to the question "Including resource file in a project by .RC file rather than .RES file").
Also include {$R mypackageicons.res mypackageicons.dcr}
to the component unit (or to the .dpk). This does not produce a '.dcr file', but sets the icon for the component.
Note that my test with a 'BMP' resource failed. I used 'BITMAP' as resource type.
I have investigated the previous responses using Delphi XE5 upd2. Not much success. So I tried to build a new solution and found one derived from previous answers.
In short: 1. Create your bitmap using Windows Paint program. 2. Create a resource script file with the bitmap. 3. Compile the script with BRCC32 to produce the dcr file 4. Include the dcr file into the package source 5. Recompile/Install the package
To automate this, it is enough to add the BRCC32 command line into the package project "pre-build events". This way, you dcr file will be recreated before each build.
For a detailed description, see my blog at http://francois-piette.blogspot.be/2014/02/howto-create-dcr-file-for-your-delphi.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With