Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit uUtils.Dialog;
- interface uses
- Vcl.Dialogs,
- Vcl.FileCtrl,
- System.SysUtils,
- IOUtils;
- type
- TDialogService = Class
- public
- class function ShowFileDialog(AFilter,ADefaultExt:String):String; overload;
- class function ShowFileDialog(ATitle,AInitialDir, AFilter, ADefaultExt:String):String; overload;
- class function SelectFolder(APath:String):String;
- End;
- implementation
- const
- SELDIRHELP = 1000;
- { TDialogService }
- class function TDialogService.ShowFileDialog(AFilter, ADefaultExt: String): String;
- begin
- result := TDialogService.ShowFileDialog(' Selecione um Arquivo. ',
- TDirectory.GetCurrentDirectory(),
- AFilter,ADefaultExt);
- end;
- class function TDialogService.SelectFolder(APath: String): String;
- var
- lDir: string;
- begin
- result := '';
- if Length(APath) <= 0 then
- lDir := TDirectory.GetCurrentDirectory()
- else
- lDir := APath;
- if SelectDirectory(lDir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
- result:= lDir;
- end;
- class function TDialogService.ShowFileDialog(ATitle,AInitialDir, AFilter, ADefaultExt : String): String;
- var
- ADialog : TOpenDialog;
- begin
- result := '';
- try
- ADialog := TOpenDialog.Create(nil);
- with ADialog do
- begin
- Title := ATitle;
- InitialDir := AInitialDir;
- Filter := AFilter;
- DefaultExt := ADefaultExt;
- if Execute then
- result := FileName;
- end;
- finally
- FreeAndNil(ADialog);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement