The following figure shows our two components (TSimple and TStringsCache) on the Designer Surface. But how do you really know that Figure 24-20 shows both a TSimple and a TStringsCache component?
Figure 24-20: The TSimple and TStringsCache components on the Designer Surface
Although the default component icon isn't ugly, you should always change it when you create a new component.
The following steps show how to create a Tool Palette icon for the TStringsCache component:
Open the Image Editor by selecting Tools ® Image Editor.
Create a new component resource file by selecting File ® New ® Component Resource File (.dcr) in the Image Editor.
Save the new .dcr file in the component's directory. The file name of the .dcr file must match the file name of the component. So, if the TStringsCache component's unit is StringsCache.pas, you have to save the .dcr file under StringsCache.dcr.
Now right-click the Contents node in the StringsCache.dcr window and select New ® Bitmap to display the Bitmap Properties dialog box (see Figure 24-21).
Figure 24-21: Creating a Tool Palette icon in the Image Editor
The Tool Palette icon should be a 24x24 bitmap, so update the Width and Height text boxes. You should also select the SuperVGA option if you want to have a nice-looking icon.
When you click OK to create the new bitmap, it will be named Bitmap1. You must change the bitmap's name to match the class name of the component. In this case, you have to rename the bitmap TStringsCache (the Image Editor will automatically convert the name to uppercase).
Now you need to draw a nice component icon.
Finally, when you're done drawing or pasting the image from an external source, save the .dcr file and return to the Project Manager.
Right-click the StringsCache.pas file in the Project Manager and select Remove from Project to temporarily remove the TStringsCache component from the package.
Right-click the package icon (Package1.bpl, or whatever it's called), select Add…, and add the StringsCache.pas file back to the package. Since the directory now contains both the .pas file and the .dcr file, the IDE will automatically add both files to the package.
Finally, recompile the package and you're done. (If you cannot see the new icon, try restarting Delphi to reload the package.)
Figure 24-22 shows the new component icon in the IDE.
Figure 24-22: The new component icon