Adding a Tool Box Icon to a VCL.Net component

Unlike Delphi 5 where you had to add the icon for your components into a resource (.DCR) file, for VCL.Net you need to include a reference to the bitmap file containing the icon in your source code.  You use the $R compiler directive for this.

First, create a 16×16, 256 colour bitmap of your icon.  Save this with the same name as your component.  For example, MyComponent.bmp.  Then add the $R directive to the source file containing the component.  It should look like this:

{$R MyComponent.bmp}

Leave a Reply