如何为我的组件创建文件夹(目录)属性编辑器?
-
13-10-2019 - |
题
Delphi 2010
如何为我的组件创建文件夹(目录)属性编辑器?
我能够使用以下方式轻松为文件名属性创建一个:
TFileProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
RegisterPropertyEditor(TypeInfo(TFileName),nil, '', TFileProperty);
我认为这可能需要更多的工作,因为我认为我需要创建一堂课才能注册,并且以某种方式致电Seldir API常规或其他东西
感谢您提供的任何帮助
解决方案
我想我有什么可以工作的,除非其他人能提出更好的事情
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;
不隶属于 StackOverflow