ImageEn, unit iexWindowsFunctions

WindowsSelectDirectory


Declaration

function WindowsSelectDirectory(const Caption: string; var Directory: string; const RootFolder: string = ''): Boolean; overload;
function WindowsSelectDirectory(Caption: string;
                                var Directory: string;
                                Parent: TWinControl;
                                AllowNewFolder: Boolean;
                                const RootFolder: string = ''): Boolean; overload;
function WindowsSelectDirectory(Caption: string;
                                var Directory: string;
                                Parent: TWinControl;
                                Options: TIEOpenFolderOptions = [foAllowNewFolder, foDisplayShareable, foDisplayFiles, foValidateFolder, foShowEditBox];
                                const RootFolder: string = ''): Boolean; overload;


Description

Displays a dialog to the user which allows the to select a folder.
If Caption is '', it will be set to "Select a Folder to Open" (localized).

For Directory and RootFolder you can specify a path or a namespace constant. The following constants are supported:
Constant Namespace Description
IEF_Desktop_Folder CSIDL_DESKTOP Windows Desktop
IEF_Drives_Folder CSIDL_DRIVES "My PC" is shown (listing all drives on the system)
IEF_Root_Directory - The drive containing Windows (usually C:\)
IEF_MyDocuments_Folder CSIDL_MYDOCUMENTS The user's "Documents" folder
IEF_MyPictures_Folder CSIDL_MYPICTURES The user's "Pictures" folder
IEF_MyVideos_Folder CSIDL_MYVIDEO The user's "Videos" folder
IEF_AppExe_Folder - The folder of the application

Note:
Similar to FileCtrl.SelectDirectory
Also available using TIEOpenFolderDialog
Uses the Windows API method: SHBrowseForFolderW()
The specified directory will be selected and expanded
If a RootFolder is not specified it defaults to EF_Desktop_Folder (CSIDL_DESKTOP) which displays My PC, Network, Control Panel, My Documents, etc.


Examples

// Allow user to select a new folder for the IEFolderMView
sFolder := IEFolderMView1.Folder;
if WindowsSelectDirectory( 'Specify Folder', sFolder, IEF_Drives_Folder ) then
  IEFolderMView1.Folder := sFolder;

// Allow selection of a folder with the "Pictures" selected and expanded
sFolder := IEF_MyPictures_Folder;
if WindowsSelectDirectory( 'Specify Folder', sFolder, IEF_Desktop_Folder ) then
  edtFolder.Text := sFolder;