Comment créer un dossier (répertoire) éditeur de propriété pour mon composant?
-
13-10-2019 - |
Question
Delphi 2010
Comment créer un éditeur de propriété Folder (Répertoire) pour mon composant?
j'ai pu créer facilement un pour une propriété FileName en utilisant:
TFileProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
RegisterPropertyEditor(TypeInfo(TFileName),nil, '', TFileProperty);
Je pense que cela peut prendre encore quelques mots travail, je pense que je dois créer une classe pour vous inscrire, et en quelque sorte appeler SELDIR routine api ou quelque chose
Merci pour toute aide que vous pourriez offrir
La solution
Je pense que je suis quelque chose à travailler, à moins que quelqu'un d'autre peut venir avec quelque chose de mieux
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;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow