| Delphi provides function for directory(folder) selection as following. uses FileCtrl;
var
dir : string;
begin
if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
begin
m_directory.Text := dir;
end;
end;
The above function is tested on Delphi 2009, but UI is more like windows 3.1.
So I recommend you to use below function which calls shell API on Microsoft Windows System.
uses ShellAPI, ShlObj;
function BrowseDialog(const Title: string; const Flag: integer): string;
var
lpItemID : PItemIDList;
BrowseInfo : TBrowseInfo;
DisplayName : array[0..MAX_PATH] of char;
TempPath : array[0..MAX_PATH] of char;
begin
Result:='';
FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
with BrowseInfo do begin
hwndOwner := Application.Handle;
pszDisplayName := @DisplayName;
lpszTitle := PChar(Title);
ulFlags := Flag;
end;
lpItemID := SHBrowseForFolder(BrowseInfo);
if lpItemId <> nil then begin
SHGetPathFromIDList(lpItemID, TempPath);
Result := TempPath;
GlobalFreePtr(lpItemID);
end;
end;
.
.
.
m_directory.Text := BrowseDialog( 'Browse for folder', 0);
|