Declaring the Register Procedure

From RAD Studio
Jump to: navigation, search

Go Up to Registering Components

Registration involves writing a single procedure in a unit of your package, which must have the name Register. The Register procedure must appear in the interface part of your unit, and (unlike the rest of Delphi) its name is case-sensitive.

Note: Although Delphi is a case-insensitive language, the Register procedure is case-sensitive and must be spelled with an uppercase R.

The following code shows the outline of a simple unit that creates and registers new components:

Delphi:

unit MyUnit;

interface

procedure Register;

implementation

procedure Register;
begin
  // …
end;

end.

C++:

namespace MyUnit
{
    void __fastcall PACKAGE Register()
    {
        // …
    }
}

Within the Register procedure, call RegisterComponents for each component that you want to add to the Tool Palette. If your unit contains several components, you can register them all in one step.

See Also