2

This documentation page keep insisting that there is a "modern looking" SelectDirectory function.

https://www.embarcadero.com/products/rad-studio/windows-development?aldSet=en-GB

New in 10 Seattle! Modern looking SelectDirectory function.

Where I can find that?

If I invoke FileCtrl.SelectDirectory a Win3.1-like dialog pop-ups: enter image description here

Is this the new modern? Or am I missing "the other" SelectDirectory function?

Gabriel
  • 20,797
  • 27
  • 159
  • 293
  • 2
    (1) There are two overloads of `SelectDirectory`, as described [here](https://stackoverflow.com/a/7422937/282848). One is Windows 3.1-styled and the other is the native Windows (95+) dialog. (2) In modern desktop applications, you should be using a standard open dialog to select directories, as described [here](https://stackoverflow.com/a/7422764/282848). (3) These options both predate Seattle, so I don't know what they are talking about. – Andreas Rejbrand Jul 07 '21 at 13:16
  • 2
    (But I have always considered the open dialog-based approach to be ... somewhat unnatural. For instance, if one directory is selected and I press Enter, then surely the file dialog will navigate to that directory? Or will the "Select Folder" button be invoked, as expected because it is the default button with a thick blue border, which will close the dialog and "return" this selected directory? Or will it return its parent, the current directory, instead?) – Andreas Rejbrand Jul 07 '21 at 13:25
  • Couldn't they have named the function something else like SelectDirectoryEx? or modern? Anyway, as you said, still not modern... – Gabriel Jul 07 '21 at 13:26
  • 3
    No, that wouldn't have been confusing enough. – Andreas Rejbrand Jul 07 '21 at 13:26
  • Since the comments there only mention it once: without _Delphi_ you get that dialog using [`SHBrowseForFolderW`](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shbrowseforfolderw) since _Windows 2000_. Done right you're able to add controls (i.e. a checkbox "recursively" or a button "create folder"). – AmigoJack Jul 07 '21 at 14:06

1 Answers1

5

Since Delphi 10 Seattle there is a third overload of SelectDirectory with the following comment:

Shows a select directory dialog using IFileDialog (recommended in Windows Vista or later).

The signature is:

function SelectDirectory(const StartDirectory: string; out Directories: TArray<string>; Options: TSelectDirFileDlgOpts = [];
  const Title: string = ''; const FolderNameLabel: string = ''; const OkButtonLabel: string = ''): Boolean; overload;
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130