Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips

#119: How can I register a custom component editor?

Today I want to show how you can register a custom component editor in Delphi IDE.

For example, you wrote some own component and want to add some menu items which will be shown in design-time popupmenu. You can assign a lot of useful "shortcut" methods there.

For example, for any export/import component I assigned two menu items: About and Execute, for report components I defined three menu items: About, Preview and Print.

Such method is very useful for components. For example, for standard TPageControl you can can in one click to add a new page or navigate by pages (Next/Prev).

For this feature you must write and register a component editor for your component:

  TyourNewComponentEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;


function TyourNewComponentEditor.GetVerbCount: Integer;
  {total number of your newest items in popup menu}
  Result := 2;

function TyourNewComponentEditor.GetVerb(Index: Integer): string;
  {names for each item}
  case Index of
    0: Result := 'Item1...';
    1: Result := 'Item2...';

procedure TyourNewComponentEditor.ExecuteVerb(Index: Integer);
  {actions for each item}
  with (Component as TyourNewComponent) do
    case Index of
      0: MethodForItem1;
      1: MethodForItem2;

and to register it:

procedure Register;
  RegisterComponentEditor(TyourNewComponent, TyourNewComponentEditor);

It's all:-)

Published: April 25, 2001

See also
Mail parser (ActiveX)
Paradox to Text converter
Database Information Manager
ABA Document Convert
Paradox to MS Access converter
Excel Reader (dll)
Paradox ActiveX
SMMsg suite
Clarion to Text converter
DBExport tools

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2019, Scalabium Software. All rights reserved.

SMExport/SMImport suites