Discussion:
DCR vs DCU
(too old to reply)
Alberto
2008-07-18 20:23:18 UTC
Permalink
I wrote a few VCL components, some from scratch using C++, some readapting free Pascal code found on Internet.
I have a few questions.

I use the DCR file format for the icons of the components, using the excellent XN Resource Editor to edit them.
Must the icon be only 24 x 24 pixels, 4bit color, or can I use also 24 bit colors ?

Sometimes I found the Pascal component that I want to modify having a .DCU file with it. I suppose it is the equivalent
of the ,DCR file, but for Delphi. Is there any way to convert it to a .DCR format ? The XN Resource Editor absolutely
refuses to open such a .DCU file. Is there some editor around that I can use ?

I am using CodeGear RAD Studio 2007 Professional.

Many thanks

Alberto di Bene
Clayton Arends
2008-07-18 21:56:49 UTC
Permalink
Post by Alberto
Must the icon be only 24 x 24 pixels, 4bit color, or can I use also 24 bit colors ?
You can use any BMP color depth you'd like. I prefer 24bit myself.
Post by Alberto
Sometimes I found the Pascal component that I want to modify having
a .DCU file with it. I suppose it is the equivalent of the ,DCR file
but for Delphi.
No. It is similar to an .obj file. Delphi uses .dcr just like C++Builder.
Afterall, DCR stands for "Delphi Compiled Resource". FYI, DCU stands for
"Delphi Compiled Unit".

HTH,
Clayton
Remy Lebeau (TeamB)
2008-07-18 23:05:41 UTC
Permalink
Post by Alberto
I use the DCR file format for the icons of the components
For components written in C++, I suggest using .RES instead. .DCR is meant
for Delphi. I've been using .RES in my components for years without any
problem.
Post by Alberto
Must the icon be only 24 x 24 pixels, 4bit color, or can I use
also 24 bit colors ?
I don't think 24-bit images are supported. I think you can use 8-bit
images, though.

As for pixel sizes, you can use 16x16, 24x24, and 32x32. Append "16" or
"32" to the name of the component bitmap for 16x16 and 32x32
bitmaps, respectively. The default bitmap size is 24x24. So, for a
component called TMyComponent, use the following bitmap names:

TMYCOMPONENT - 24x24
TMYCOMPONENT16 - 16x16
TMYCOMPONENT32 - 32x32
Post by Alberto
Sometimes I found the Pascal component that I want to modify
having a .DCU file with it. I suppose it is the equivalent of the
,DCR file, but for Delphi.
No, it is not. A .DCU file is a compiled Pascal unit, similar to .obj for
.cpp files in C++. Component vendors who do not want to provide their
source code must provide .DCU files for each supported compiler version
instead.
Post by Alberto
Is there any way to convert it to a .DCR format ?
No, because .DCU is not for resources to begin with.
Post by Alberto
The XN Resource Editor absolutely refuses to open such a .DCU file.
As it should.


Gambit
Alberto
2008-07-20 16:10:25 UTC
Permalink
Post by Remy Lebeau (TeamB)
For components written in C++, I suggest using .RES instead. .DCR is meant
for Delphi. I've been using .RES in my components for years without any
problem.
Thanks for the suggestion. I had in fact already asked to myself which the conceptual difference between DCR and RES
files could be, but you are now confirming to me that there is none, only one related to the language used.
Post by Remy Lebeau (TeamB)
I don't think 24-bit images are supported. I think you can use 8-bit
images, though.
Well I tried with 24-bit colors (8 bits per components R,G,B), and apparently they work.
Post by Remy Lebeau (TeamB)
No, it is not. A .DCU file is a compiled Pascal unit, similar to .obj for
.cpp files in C++. Component vendors who do not want to provide their
source code must provide .DCU files for each supported compiler version
instead.
Thanks. Mystery solved. But now I have another question....

When I compile my component library as a package, after the final linking I click on Component | Install Packeges...
then I select my library and click on Components. At this point I am able to see all my components with the correct
icons. Then I close the package and open a project that makes use of that library. When editing a form, on the right
side of the screen there is a palette of components that I can use on that form. I select the tab with the name I gave
to my library, but the components are then listed there with the default icon of three geometric shapes used when you
did not provide a DCR (or RES) file for that component.

And this is not the only weirdness... a few (only a few) of the components have an icon, but *not* the icon I put in the
DCR file... it is like the compiler had searched in the wrong place to find my icons...
Before you ask, yes, I made sure that the name of the bitmap in the DCR file was T followed by the name of the component
in capital case. and set to "Language Neutral"

I'm scratching my head on this already since some time, but haven't found so far a solution...

Thanks for any help

Alberto di Bene
Remy Lebeau (TeamB)
2008-07-21 06:27:32 UTC
Permalink
I select the tab with the name I gave to my library, but the components
are then listed there with the default icon of three geometric shapes
The BCB2007 IDE has some issues with component icons like that. Don't know
why.
used when you did not provide a DCR (or RES) file for that component.
Another reason I like .RES versus .DCR is that the .RES file can be compiled
directly into the package binary, whereas DCR is an external file.
a few (only a few) of the components have an icon, but *not* the icon I
put in the DCR file... it is like the compiler had searched in the wrong
place
to find my icons...
It probably is.


Gambit

Loading...