开发者

How to create a Folder (Directory) property editor for my component?

Delphi 2010

How to create a Folder (Directory) property editor for my component?

I was able to easily create one for a FileName property using:

TFileProperty = class(TStringProperty)  
public  
  function开发者_Python百科 GetAttributes: TPropertyAttributes; override;  
  procedure Edit; override;  
end;  

RegisterPropertyEditor(TypeInfo(TFileName),nil, '', TFileProperty);  

I think it may take alittle more work, as i think i need to create a class to register, and somehow call selDir api routine or something

thanks for any help you may offer


I think i got something to work, unless someone else can come up with something better

type  
  TFolderName = String;  

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

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

procedure TFolderNameProperty.Edit;  
var  
  Dir: String;  
begin  
  SelectDirectory('Select a directory', '', Dir)  
  SetValue(Dir);  
end {Edit};  

procedure Register;  
begin  
  RegisterPropertyEditor(TypeInfo(TFolderName),nil, '', TFolderNameProperty)  
end;  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜