1. SelectDirectory( Title, RootDir, DirSelected ) displays the standard Windows "Browse for Folder" dialog with a directory tree. The parameters are:
2. SelectDirectory( Dir, Options, HelpCtx ) shows an additional edit-box above the directory tree. The parameters:
In both cases, the function returns TRUE if a folder was selected, otherwise FALSE. |
|
How to use this Delphi function? Two examples, correspondig with the pictures above:
// Syntax 1
procedure TForm1.Button1Click(Sender: TObject);
var
DirSelected: string;
begin
if SelectDirectory('Select a folder:', 'D:\Delphi', DirSelected) then
ShowMessage('You selected ' + DirSelected)
else
ShowMessage('You did not select a folder');
end;
// Syntax 2
procedure TForm1.Button2Click(Sender: TObject);
var
Dir: string;
begin
Dir := 'D:\Delphi';
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
ShowMessage('You selected ' + Dir)
else
ShowMessage('You did not select a folder');
end;
IMPORTANT: SelectDirectory only works if you add FileCtrl to the uses-directive near the top of your unit. For example, if it is:
uses Windows, Messages, ..., StdCtrls;
change it to:
uses Windows, Messages, ..., StdCtrls, FileCtrl;
|
Crash Course Delphi |
Become member of the DelphiLand Club and get our Crash Course Delphi, plus the fully commented source code of all our tutorial projects, plus guaranteed answers from our Q/A Forum. Membership is for life. |
TOP :: Source
Code and Tutorials :: Crash Course Delphi :: Forum
DelphiLand Club :: TURBO
Delphi Explorer FAQ :: DC Library :: Tips :: Downloads :: Links
© Copyright 1999-2007
Studiebureau Festraets