TFileOpenDialog in FireMonkey app

I use FireMonkey and I want the user to select a directory using the interface provided by TFileOpenDialog (I believe the SelectDirectory interface is outdated at best - yes, even with the sdNewUI option).

TFileOpenDialog with [fdoPickFolders] option

Firstly, is it inconvenient to use VCL.Dialogs (use TFileOpenDialog) in a FireMonkey application?

Secondly, this is only possible on Windows Vista and higher. Is this the right way to check compatible versions of Windows?

{IFDEF WIN32 or WIN64} if Win32MajorVersion >= 6 then // Create TOpenFileDialog with fdoPickFolders option 
+4
source share
2 answers

For future use, use IFileDialog to create a dialog box with a folder of Windows Vista and higher:

 uses ShlObj, ActiveX; ... var FolderDialog : IFileDialog; hr: HRESULT; IResult: IShellItem; FileName: PChar; Settings: DWORD; begin if Win32MajorVersion >= 6 then begin hr := CoCreateInstance(CLSID_FileOpenDialog, nil, CLSCTX_INPROC_SERVER, IFileDialog, FolderDialog); if hr = S_OK then begin FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_PICKFOLDERS); FolderDialog.GetOptions(Settings); FolderDialog.SetOptions(Settings or FOS_FORCEFILESYSTEM); FolderDialog.SetOkButtonLabel(PChar('Select')); FolderDialog.SetTitle(PChar('Select a Directory')); hr := FolderDialog.Show(Handle); if hr = S_OK then begin hr := FolderDialog.GetResult(IResult); if hr = S_OK then begin IResult.GetDisplayName(SIGDN_FILESYSPATH,FileName); ConfigPathEdit.Text := FileName; end; end; end; end; end; 
+2
source
 if SelectDirectory('Select a directory', chosenDirectory, chosenDirectory) then 
0
source

All Articles