Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most common way to create a folder selection dialog using Delphi?

There doesn't appear to be a simple component available to create a folder selection dialog in Delphi 2009, although a file selection dialog is provided by way of the TOpenDialog.

What is the most common way to create a modern folder selection dialog using Delphi?

like image 395
Rowan Avatar asked Aug 17 '09 05:08

Rowan


3 Answers

There are two overloaded routines in FileCtrl.pas called SelectDirectory

For a modern look, use the second form, with sdNewUI

var
  dir : string;
begin
  dir := 'C:\temp';
  FileCtrl.SelectDirectory('Select', 'C:\', dir, [sdNewFolder, sdNewUI], Self);
end;

NOTE: sdNewFolder, sdNewUI etc are only available from D2006+

like image 180
Gerry Coll Avatar answered Nov 05 '22 21:11

Gerry Coll


you can use SelectDirectory from FileCtrl unit

using FileCtrl;
var
  St: string;
begin
  St:='c:\';
  if SelectDirectory(St,[],0) then 
  begin
  end;

end;
like image 28
Wael Dalloul Avatar answered Nov 05 '22 19:11

Wael Dalloul


You can download a component PBFolderDialog from "http://bak-o-soft.dk/Delphi/PBFolderDialog.aspx" which is quite easy to use and offers access to all options of the Windows "SHBrowseForFolder" dialog; something which the built-in ones not do.

It's freeware with source and not too difficult to port to Delphi 2009.

like image 1
Olaf Hess Avatar answered Nov 05 '22 19:11

Olaf Hess