给你一个例子,看看,我刚刚写的测试
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,DesignIntf,DesignEditors, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
TComponent1 = class(TComponent)
private
FStringEx: string;
procedure SetStringEx(const Value: string);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property StringEx: string read FStringEx write SetStringEx;
end;
TTestProperty = class(TPropertyEditor)
FDataString: string;
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
function Execute: string;
procedure Register;
implementation
{$R *.dfm}
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(string), TComponent1,'StringEx',TTestProperty);
RegisterComponents('Samples', [TComponent1]);
end;
{ TPDFDataStringProperty }
procedure TTestProperty.Edit;
begin
inherited;
Execute;
end;
function TTestProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TTestProperty.GetValue: string;
begin
end;
function Execute: string;
begin
with TForm1.Create(Application) do
begin
Position := poDesktopCenter;
ShowModal;
end;
end;
{ TComponent1 }
procedure TComponent1.SetStringEx(const Value: string);
begin
FStringEx := Value;
end;
end.