عليك اضافة Package خاصة بالتصميم منفصلة عن ال Package الخاصة بال RunTime
ضمن ال Packge الجديدة، انقل اليها تسجيل العناصر الخاصة بك، على ملف unit خاص بها، ضمن هذا الملف، سنضيف ال Property Editor
يوجد نوعين منها، واحد على مستوى العنصر ككل، وواحد على مستوى الخاصية نفسها
النوع الاول قم باشتقاق TDefaultEditor
الثاني وهو ما تريده قم باشتقاق TPropertyEditor
و فيالاجراء Register اضف هاذين الكلاسين
المثال التالي يحوي الاثنين معا، طبعا لم اجربهم قد يحتويان على اخطاء بسيطة، لكنك ببساطة يمكن بحث عن امثلة حقيقية ضمن المصدر الدلفي، ابحث عن TColor مثلا، او Memo.Lines ايضا لها شاشة خاصة
{
TMyComponentEditor
}
TMyEditor = class(TDefaultEditor)
protected
public
constructor Create(AComponent: TComponent; ADesigner: TComponentEditorDesigner); override;
procedure Edit; override;
procedure ExecuteVerb(Index: integer); override;
function GetVerb(Index: integer): string; override;
function GetVerbCount: integer; override;
procedure PrepareItem(Index: integer; const AnItem: TMenuItem); override;
end;
constructor TMyEditor.Create(AComponent: TComponent; ADesigner: TComponentEditorDesigner);
begin
inherited Create(AComponent, ADesigner);
BestEditEvent := 'MyProp'; //Property if clicked do the same
end;
procedure TMyEditor.Edit;
begin
///....
end;
procedure TMyEditor.ExecuteVerb(Index: integer);
begin
case Index of
0: Edit;
1: Anotheraction;
end;
end;
function TMyEditor.GetVerb(Index: integer): string;
begin
case Index of
0: Result := 'Action';
1: Result := 'Another Action';
end;
end;
function TMyEditor.GetVerbCount: integer;
begin
Result := 2;
end;
procedure TMyEditor.PrepareItem(Index: integer; const AnItem: TMenuItem);
begin
inherited;
end;
{
TMyPropertyEditor
}
TMyPropertyEditor = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue:string; override;
end;
procedure TAutoCorrectionProperty.Edit;
var
MyComponent : TMyComponent;
begin
MyComponent := TMyComponent(GetComponent(0)); //yes it is a list , you can take all component not just one, but here we will take one
MyShowForm(MyComponent);
Designer.Modified;
end;
function TAutoCorrectionProperty.GetAttributes: TPropertyAttributes;
begin
GetAttributes := [paDialog, paReadOnly]; //
end;
function TAutoCorrectionProperty.GetValue: string;
begin
GetValue := '(myvalue)'; //sepical show value
end;
procedure Register;
begin
RegisterComponentEditor(TMyComponent, TMyEditor);
RegisterPropertyEditor(TypeInfo(TMyType), TMyComponent, 'MyProp', TMyPropertyEditor);
end;