Registering the Component Editor

From RAD Studio
Jump to: navigation, search

Go Up to Adding Component Editors

Once the component editor is defined, it can be registered to work with a particular component class. A registered component editor is created for each component of that class when it is selected in the form designer.

To create the association between a component editor and a component class, call RegisterComponentEditor. RegisterComponentEditor takes the name of the component class that uses the editor, and the name of the component editor class that you have defined. For example, the following statement registers a component editor class named TMyEditor to work with all components of type TMyComponent:

RegisterComponentEditor(TMyComponent, TMyEditor);
RegisterComponentEditor(__classid( TMyComponent), __classid(TMyEditor));

Place the call to RegisterComponentEditor in the Register procedure where you register your component. For example, if a new component named TMyComponent and its component editor TMyEditor are both implemented in the same unit, the following code registers the component and its association with the component editor.

procedure Register;
  RegisterComponents('Miscellaneous', [TMyComponent);
  RegisterComponentEditor(classes[0], TMyEditor);
namespace Newcomp
  void __fastcall PACKAGE Register()

    RegisterComponents("Miscellaneous", classes, 0);
    RegisterComponentEditor(classes[0], __classid(TMyEditor));