Как программно вызвать метод «Edit» свойства компонента в delphi? - PullRequest
0 голосов
/ 13 мая 2019

Я создаю простой компонент, который хранит свойства 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;

Простите, если я дублирую вопрос, но я действительно не смог найти вопрос, который ответил на мой вопрос.

...