unit PropEditorComponent_dsgn;
interface
uses
SysUtils, Classes, Dialogs, PropEditorComponent, DesignIntf, DesignEditors;
type
TMyPropertyEditorEins =
class(TClassProperty)
function GetAttributes: TPropertyAttributes;
override;
function GetValue:
string;
override;
end;
TMyPropertyEditorZwei =
class(TClassProperty)
procedure Edit;
override;
function GetAttributes: TPropertyAttributes;
override;
function GetValue:
string;
override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Beispiele', [TPropEditorComponent]);
RegisterPropertyEditor(TypeInfo(TMyPropertyEins),
nil, '
', TMyPropertyEditorEins);
RegisterPropertyEditor(TypeInfo(TMyPropertyZwei),
nil, '
', TMyPropertyEditorZwei);
end;
{ TMyPropertyEditor1 }
function TMyPropertyEditorEins.GetAttributes: TPropertyAttributes;
begin
Result := [];
end;
function TMyPropertyEditorEins.GetValue:
string;
var
s:
string;
begin
// Nein, so macht man das besser nicht :-), ist ja nur zur Demo
s := '
SuperDuper="'+TMyProperty(GetOrdValueAt(0)).SuperDuper+'
", Zahl='+IntToStr(TMyProperty(GetOrdValueAt(0)).Zahl);
FmtStr(Result, '
(%s)', [s]);
end;
{ TMyPropertyEditorZwei }
procedure TMyPropertyEditorZwei.Edit;
begin
// Nein, so macht man das besser nicht :-), ist ja nur zur Demo
ShowMessage('
SuperDuper="'+TMyProperty(GetOrdValueAt(0)).SuperDuper+'
", Zahl='+IntToStr(TMyProperty(GetOrdValueAt(0)).Zahl));
end;
function TMyPropertyEditorZwei.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TMyPropertyEditorZwei.GetValue:
string;
begin
FmtStr(Result, '
(%s)', ['
Abrakadabra']);
end;
end.