views:

119

answers:

2

I am building a delphi non-visual component. How do I set the image I want it to have in the IDE?

+11  A: 

Tim, you must create a .dcr file with the name of your unit in the same directory of the .pas component source file. then add to the dcr file a 24x24 bitmap called with the name of the component class something like TMyNonVisualComp.

finally you must add this line to the unit {$R your_dcr_file.DCR}

Check theses links for more info

RRUZ
Optionally together with 'TMyNonVisualComp16' and 'TMyNonVisualComp32' with 16x16 and 32x32 px sized bitmaps respectively for small and large tool palette icons.
Sertac Akyuz
@RRUZ: the name of the .dcr does not need to match the name of the unit. However, the bitmap inside of it does need to match the class name, yes. What you left out is that the bitmap name needs to be in all-caps, ie TMYNONVISUALCOMP.
Remy Lebeau - TeamB
As Remy said: The name of the dcr can be different from the unit name, but for convenience, if it is the same, you could use{$R *.dcr} in the unit rather than the full name.
dummzeuch
A: 

You just need to make icon for this component that will also be shown in component palette, same way you are doing this for visual components. In short words, make MyComponent.dcr file for component MyComponent.pas and add this file to package with this component. You can use Delphi Image Editor to make dcr.