Description |
The SelectDirectory displays a dialog allowing the user to select a directory ChosenDirectory (drive plus path).
Version 1.
This displays a Windows browser dialog, initialised to the specified StartDir. The Caption text is shown at the top of the dialog.
If the user presses OK, then the selected directory is returned in the ChosenDir variable, and the return value is True.
If the user presses Cancel, then no output is given, and the return value is False.
Version 2.
This displays a very different type of dialog, that incidently shows the files in the currently selected directory.
The CurrDir value is used to position the display to the given directory, and is updated with the selected value if the user presses OK.
The DialogOptions and HelpContext parameters are beyond the scope of this article. They may safely be left to default values, as in the given example.
|
|
Related commands |
|
|
|
Example code : Let the user select a dialog using the first version |
var
chosenDirectory : string;
begin // Ask the user to select a required directory, starting with C:
if SelectDirectory('Select a directory', 'C:\', chosenDirectory)
then WriteLn('Chosen directory = '+chosenDirectory)
else WriteLn('Directory selection aborted');
end;
|
Show full unit code |
{ Dialog displays - user selects C:\Program Files and hits OK }
Chosen directory = C:\Program Files
|
|
Example code : Let the user select a dialog using the second version |
var
options : TSelectDirOpts;
chosenDirectory : string;
begin chosenDirectory := 'C:\'; // Set the starting directory // Ask the user to select using a completely different dialog!
if SelectDirectory(chosenDirectory, options, 0)
then WriteLn('Chosen directory = '+chosenDirectory)
else WriteLn('Directory selection aborted');
end;
|
Show full unit code |
{ Dialog displays - user selects C:\Program Files and hits Cancel }
Directory selection aborted
|
|