我正在构建一个简单的组件,用于存储Tfont的属性。正常工作,但我想实现对组件属性的默认编辑器的调用。我已经在Google和此处进行了大量搜索,并尝试了一些方法,但是我无法以编程方式调用“默认编辑器”。组件和发布者代码如下:
type TMyPersistentFont = class(TComponent)
var
FOwner: TPersistent;
private
FProperties: TFont;
procedure SetProperties(const Value: TFont);
protected
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TComponent); override;
published
property Properties: TFont read FProperties write SetProperties;
end;
...
type
TMyPersistentFontEditor = class(TComponentEditor)
function GetVerbCount: Integer; override;
function GetVerb(Index: Integer): string; override;
procedure ExecuteVerb(Index: Integer); override;
//
procedure Edit; override;
end;
procedure TMyPersistentFontEditor.ExecuteVerb(Index: Integer);
begin
inherited;
case Index of
0:
begin
var FontDlg:= TFontDialog.Create(Component);
FontDlg.Font.Assign(TMyPersistentFont(Component).Properties);
try
if FontDlg.Execute then
begin
TMyPersistentFont(Component).Properties.Assign(FontDlg.Font);
Designer.Modified;
end;
finally
FontDlg.Free
end;
end;
//TPropertyEditor(TMyPersistentFont(Component).Properties).Edit; //don't works
end;
end;
如果我要重复该问题,请原谅我,但是,我确实找不到能回答我问题的问题。