PDA

View Full Version : Component Icon



xGTx
19-05-2005, 06:14 PM
I've been creating my own set of components for a few things that I like to use throughout many projects and I would like to add Icon's to the component that's displayed in the delphi ide. Im not sure how this is done. Anyone can walk thru it real fast?

Harry Hunt
19-05-2005, 06:40 PM
You need to make a DCR file with the icon in it.

Create a Bitmap first. The size shouldn't exceed 24x24 or it will get clipped. Any color depth is fine (although alpha transparency isn't supported).

Now you need to create a resource file. Either use the Image Editor that comes with Delphi or use the borland resource compiler (BRCC32.exe, can be found in the \bin folder) and a resource script. Make sure you name the bitmap resource identical to the class name you're creating the icon for. So if your class is called TMyButton the Bitmap resource should be called TMYBUTTON. I'm pretty sure the all-uppercase is required.

I recommend using a resource script since that will allow you to create better looking icons (the image editor is restricted to 256 colors and the windows default palette).

Name the resource file the same as your .PAS file and give it a .DCR extension. That should do the trick.

Note that the pixel in the lower left corner of your image will be used to determine the color for transparency.

xGTx
20-05-2005, 01:21 AM
Not working :P

JSoftware
20-05-2005, 09:44 AM
{R *.dcr}

you need this to be in the main file jsut right after implementation

Harry Hunt
20-05-2005, 01:40 PM
Not working :P
ungrateful bastard :P

xGTx
20-05-2005, 04:46 PM
:cry: I didn't mean to be rude if i was :( Harry

Harry Hunt
20-05-2005, 09:29 PM
:cry: I didn't mean to be rude if i was :( Harry

i was kidding of course.

xGTx
20-05-2005, 09:42 PM
You scared me. :shock:

xGTx
20-05-2005, 09:50 PM
Sweet... Got it working, thanks guys :)