Scalabium Software

SMExport advertising
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:

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

where

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

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

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

and to register it:

procedure Register;
begin
  RegisterComponentEditor(TyourNewComponent, TyourNewComponentEditor);
end;

It's all:-)


Published: April 25, 2001

See also
 
MAPIMail
SMImport suite
Metafile Convert
ABA Database Convert
Protected Storage Viewer
Paradox ActiveX
Paradox to MS Access converter
DBISAM Password Recovery
ABA Document Convert
SMMsg suite
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2018, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport/SMImport suites