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

4

7

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?

Seals answered 17/8, 2009 at 5:0 Comment(0)
S
16

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+

Seibert answered 17/8, 2009 at 5:9 Comment(3)
Thanks for that. I did look at SelectDirectory previously but I didn't see the option for the modern UI.Seals
A list of the available options in the Options parameter for SelectDirectory can be found here: docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/…Seals
Using FileCtrl.pas gives me a warning: Unit "FileCtrl" is specific to a platform. Is there a solution without this unit?Ishmael
G
2

you can use SelectDirectory from FileCtrl unit

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

end;
Gabelle answered 17/8, 2009 at 5:11 Comment(0)
W
1

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.

Warrior answered 18/8, 2009 at 16:14 Comment(0)
M
0

See the sample code:


Delphi tip#157: select folder dialog http://www.scalabium.com/faq/dct0157.htm


Mandate answered 17/8, 2009 at 9:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.