unit StrEditor;

interface

uses Windows,Classes, Controls, StdCtrls,Buttons, TypInfo,Forms,ExtCtrls,{$IFDEF VER140}DesignIntf, VCLEditors
  {$ELSE}DsgnIntf{$ENDIF};

type
  TStrEditDlg = class(TForm)
    Memo: TMemo;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    Bevel1: TBevel;
    BtnAbout: TBitBtn;
    Label1: TLabel;
    procedure BtnAboutClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure CreateParams(var Param:TCreateParams);override;
  end;

type
  TCaptionEditor = class(TCaptionProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

{$R *.DFM}

procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(TCaption), TObject, 'Caption', TCaptionEditor);
  RegisterPropertyEditor(TypeInfo(TCaption), TObject, 'Text', TCaptionEditor);
  RegisterPropertyEditor(TypeInfo(string), TObject, 'Hint', TCaptionEditor);
end; { Register }

{ THintProperty }

procedure TCaptionEditor.Edit;
var
  Comp              : TPersistent;
begin
  with TStrEditDlg.Create(Application) do
  try
    Comp := GetComponent(0);
    if Comp is TComponent then
      Caption := TComponent(Comp).Name + '.' + GetName
    else
      Caption := GetName;
    Memo.Text :=GetStrValue;
    Memo.SelectAll;
    if ShowModal = mrOk then
      SetStrValue(Memo.Text);
  finally
    Free;
  end;
end; { TCaptionEditor.Edit }

function TCaptionEditor.GetAttributes: TPropertyAttributes;
begin
  Result := inherited GetAttributes + [paDialog];
end; { TCaptionEditor.GetAttributes }

procedure TStrEditDlg.BtnAboutClick(Sender: TObject);
begin
  MessageBox(Handle,'Copyright (C) Kingron 2002','Info',MB_OK+MB_ICONINFORMATION);
end; { TStrEditDlg.BtnAboutClick }

procedure TStrEditDlg.CreateParams(var Param: TCreateParams);
begin
  inherited;
  Param.WndParent :=GetActiveWindow;
end;

end.

