Registering component editors uses RegisterComponentEditor() and is straightforward. Its declaration is
extern PACKAGE void __fastcall RegisterComponentEditor(TMetaClass* ComponentClass, TMetaClass* ComponentEditor);
This must be called inside the package's Register() function. Only two parameters are required. Both parameters will be TObject descendants, so the __classid operator can be used to obtain a TMetaClass pointer for each. The first parameter is the component class for which the component editor is to be registered. The second parameter is the component editor class itself. For example, to register a custom TImage component editor called TImageComponentEditor , you would write the following:
RegisterComponentEditor(__classid(TImage), __classid(TImageComponentEditor));
Component editors are like property editors in that they are used from newest to oldest. As a result, it is possible to override existing component editors in preference to custom component editors offering greater capabilities.
Also as with property editors, it is possible to register component editor packages without components . This has been done with the TImageComponentEditor component editor discussed previously. It is included in the package containing the enhanced property editors developed in the "Using Images in Property Editors" section, earlier in this chapter.
Top |