We help IT Professionals succeed at work.

Change the component icon in the component palette of IDE

skyrider_tieus
on
Any expert knows to change the component icon in the IDE palette?

Comment
Watch Question

Commented:
Say your component is of type TMyType

Using the image editor that comes with Delphi...

Create a .dcr file called MyType.dcr in the same directory as the MyType.pas component source file.
In the .dcr file create a new (24x24) bitmap called TMyType.

Then recompile the package and the bitmap should appear in the palette.

Cheers
Paul

Commented:
Using the Image Editor Open the *.res file for the *.dpk file that has the components to change.

FYI: The palette images are bitmaps(16 x 16)

Create or edit the bitmaps for each component in the Package file thes name of the bitmap should match the name of the component. (i.e. Component name = TTrace, Bitmap name = TTrace)

When you done save the changes next time you load the components in the IDE the images should be changed.

Good Luck,
RH.

Author

Commented:
Thanks Guy!

How about change the component icon with an existing bitmap or icon?  I don't want to create the bitmap myself.

Author

Commented:
Zebada:
  I tried your suggestion, but it won't work!  The palette displayed the delphi's default icon for my control.  The container is Delphi 6.

Author

Commented:
Zebada:
  I tried your suggestion, but it won't work!  The palette displayed the delphi's default icon for my control.  The container is Delphi 6.

Author

Commented:
RHuebner:

Could you be more specific where to locate the *.res for *.dpk?
Igor UL7AAjrSenior developer

Commented:
Hi skyrider_tieus,
Paul (zebada)  was right, there is the way to do.
And right icon size is 24x24 instead of 16x16.
btw, there should be line in source code to link dcr file:
{$R *.DCR}

-----
Igor

PS: not sure about D6.

Commented:
The *.res files for the common components are located in the c:\program files\borland\delphi5\lib\*.res

The *.dpk files are where you save them and there are *.res files should be with them.

I haven't used D6 yet, but this is where you find it in D5.

RH.

Author

Commented:
Hi Igor!

Welcome joining the discussion.  My control is developed in VC++, not in delphi.  Your suggestion {$R *.DCR} is a Delphi directive.  In the first place I imported the control thru type library, and the component icon displayed the origianl icon by VC++.  
Then I tried to change the component icon by editing the dcr file under folder ...\imports with Delphi image editor as suggested by Paul.   The component icon in the palette turn out the Delphi default icon, which could not be altered ever since including an bitmap created in the image editor.  Btw, the package has been recompiled.  

Author

Commented:
Hi RHuebner:

I opened dcluser.dpk and dcluser.res in the folder, but the bitmaps in the res file seemed nothing to do with the components icon.  They looked more like the button icon.

Author

Commented:
Igor:

I tried to put the {$R *.DCR} in the component pas unit and recompile the package.  Errors occurred.  

Commented:
Ok i imported my controls from vs6, you'll have to edit the image in the *.dcr file, when your done you have to recompile the *.dpk the components are in, easy enough right.

apprently,
when you create a component in delphi you edit the *.res,
and when you import or have a compile component you edit the *.dcr

RH.

Author

Commented:
When I first edited the icon, I deleted the old bitmap and created a new one.  Somehow the component icon was messed up.  The component sticked to the default icon no matter how I modified and recompiled it.  So I image-modified a new component without deleting it, and it worked.  This is not a happy news to me since I could only modified an existing bitmap rather than import a new bitmap.  Any idea on this?  

Commented:
Did you Remember to name the image exactlly the same as the component name.

RH.

Author

Commented:
RH!

You are right.  The name of bitmap matters.  problem solved!  I'd like to apportion points between Zebada and you.  It's hard to decide! If you could tell me how to import a bitmap into image editor, you'll get the whole credit and I'll post points for Zebada.

Thanks!

Commented:
File->Open, select file type: Bitmap and load the bitmap.
or
Use your favourite bitmap editor, (I use Paintshop Pro) select the bitmap, copy it to the clipboard and then paste it into an open bitmap in Delphi's image editor

Commented:
I think zedaba said it all, the delphi image editor is nice but lacks file importing so the easiest way and the way i do it is to copy and paste.

RH.
Points reduced to 50 for point split.

Thank you
Computer101
Community Support Moderator

Author

Commented:
Find the *.dcr file for the component and use image editor to modify the icon.  However, RHeubner brought to the attention to assure the name of the bitmap should match that of the component.  That worths some points.