[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
RegisterEditor
Welcome to Component Writer's Help - Editors
Registering your Editors
Hint: When writing your editors, write them in a separate file (example MyEditors.pas). That way, you will not need to include them in your applications (uses clause) each time you want to use your custom components.
Let's say you have a component called MyComponent which has a property of type TPath. You would like a Dialog to appear when a user (programmer) wants to change any of your properties of type TPath.
For a dialog to appear, you need to create a TPath editor called TPathProperty.
You can find help on creating you property editors in other usefull pages of this CodePedia section.
For now, let's just look at how to register your property editor. (Code below).
RegisterPropertyEditor(TypeInfo(TPath), TMyComponent, '', TPathProperty);
TypeInfo(TPath)
Tells the editor the needed information on your custom type. This is the type to associate to your editor.
TMyComponent
Tells the editor that your custom type can be found in this component.
'' (Empty string)
You can specify a property name. If blank, any property of type TPath in your TMyComponent will be associated with this property editor.
TPathEditor
Your editor !!!
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
RegisterEditor
Welcome to Component Writer's Help - Editors
Registering your Editors
Hint: When writing your editors, write them in a separate file (example MyEditors.pas). That way, you will not need to include them in your applications (uses clause) each time you want to use your custom components.
Let's say you have a component called MyComponent which has a property of type TPath. You would like a Dialog to appear when a user (programmer) wants to change any of your properties of type TPath.
For a dialog to appear, you need to create a TPath editor called TPathProperty.
You can find help on creating you property editors in other usefull pages of this CodePedia section.
For now, let's just look at how to register your property editor. (Code below).
RegisterPropertyEditor(TypeInfo(TPath), TMyComponent, '', TPathProperty);
TypeInfo(TPath)
Tells the editor the needed information on your custom type. This is the type to associate to your editor.
TMyComponent
Tells the editor that your custom type can be found in this component.
'' (Empty string)
You can specify a property name. If blank, any property of type TPath in your TMyComponent will be associated with this property editor.
TPathEditor
Your editor !!!
unit uMyEditors;
interface
uses SysUtils, StrUtils, Classes, DesignEditors, DesignIntf;
{name change in D6 pro Update 2}
//DesignIntf is the name for Delphi 6 Pro
//DsgnIntf is the name for Delphi 5 Pro
type
TPathProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
type
TMyComponentEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
procedure Register;
implementation
uses uMyComponent;
procedure Register;
begin
RegisterComponents('Standard', [TMyComponent]);
RegisterPropertyEditor(TypeInfo(TPath), TMyComponent, '', TPathProperty);
RegisterComponentEditor(TMyComponent, TMyComponentEditor);
end;
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
