// Found this example in the article :
//    "Property and Component Editors"
// at http://www.drbob42.com

unit FileName;
interface
uses
  SysUtils, DsgnIntf;

type
  TFileNameProperty = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

procedure Register;

implementation
uses
  Dialogs, Forms;

function TFileNameProperty.GetAttributes: TPropertyAttributes;
  begin
    Result := [paDialog]
  end {GetAttributes};

procedure TFileNameProperty.Edit;
  begin
    with TOpenDialog.Create(Application) do
    try
      Title := GetName; { name of property as OpenDialog caption }
      FileName := GetValue;
      Filter := 'All Files (*.*)|*.*';
      HelpContext := 0;
      Options := Options + [ofShowHelp, ofPathMustExist, ofFileMustExist];
      if Execute then SetValue(FileName);
    finally
      Free
    end
  end {Edit};

procedure Register;
  begin
    RegisterPropertyEditor(TypeInfo(TFileName), nil, '', TFileNameProperty)
  end;

end.

Delphi Snippets - jun 1999 - Arnulf Sortland