propedit.pas

来自「类似Delphi Ide的对象查看器 可以在RUNTIME时使用」· PAS 代码 · 共 63 行

PAS
63
字号
unit PropEdit;

interface

uses Classes, Graphics, PropList, Dialogs;

type

  TPropertyEditor = class
  private
    FProp: TProperty;
  public
    constructor Create(AProp: TProperty); virtual;
    function Execute: Boolean; virtual; abstract;
    property Prop: TProperty read FProp;
  end;

  TPropertyEditorClass = class of TPropertyEditor;

  TFontPropertyEditor = class(TPropertyEditor)
  public
    function Execute: Boolean; override;
  end;

  TColorPropertyEditor = class(TPropertyEditor)
  public
    function Execute: Boolean; override;
  end;

implementation

constructor TPropertyEditor.Create(AProp: TProperty);
begin
  inherited Create;
  FProp:=AProp;
end;

function TFontPropertyEditor.Execute: Boolean;
begin
  with TFontDialog.Create(nil) do
  try
    Font.Assign(TFont(Prop.AsObject));
    Result:=Execute;
    if Result then TFont(Prop.AsObject).Assign(Font);
  finally
    Free;
  end;
end;

function TColorPropertyEditor.Execute: Boolean;
begin
  with TColorDialog.Create(nil) do
  try
    Color:=Prop.AsInteger;
    Result:=Execute;
    if Result then Prop.AsInteger:=Color;
  finally
    Free;
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?