Recent

Author Topic: Dialog for selecting both files and directories  (Read 2201 times)

simsee

  • Full Member
  • ***
  • Posts: 196
Dialog for selecting both files and directories
« on: January 05, 2025, 01:36:13 pm »
With TOpenDialog I can select files, while with TSelectDirectoryDialog I can select directories. Is there a dialog that allows you to select both files and directories?

If I remember correctly, in Delphi there is TFileOpenDialog with fdoPickFolders option, but I can't seem to find anything similar in Lazarus.

Thanks.

ASerge

  • Hero Member
  • *****
  • Posts: 2376
Re: Dialog for selecting both files and directories
« Reply #1 on: January 05, 2025, 03:39:39 pm »
If I remember correctly, in Delphi there is TFileOpenDialog with fdoPickFolders option, but I can't seem to find anything similar in Lazarus.
In Lazarus, this is "ofPickFolders". This is the same as in Delphi fdoPickFolders, and allows you to select folders ONLY.

Bart

  • Hero Member
  • *****
  • Posts: 5510
    • Bart en Mariska's Webstek
Re: Dialog for selecting both files and directories
« Reply #2 on: January 05, 2025, 03:47:35 pm »
If I remember correctly, in Delphi there is TFileOpenDialog with fdoPickFolders option, but I can't seem to find anything similar in Lazarus.
In Lazarus, this is "ofPickFolders". This is the same as in Delphi fdoPickFolders, and allows you to select folders ONLY.

And that behaviour is the native behaviour of Windows, since we just tell Windows to apply that flag (FOS_PICKFOLDERS).
Microsoft says:
Quote
FOS_PICKFOLDERS: Present an Open dialog that offers a choice of folders rather than files.

I'm also not sure how "pick a folder and pich a filename" is supposed to work.
If I double click on a folder, wil it open the folder or pick it.
Either behaviour may not be what the user expected.

simsee

  • Full Member
  • ***
  • Posts: 196
Re: Dialog for selecting both files and directories
« Reply #3 on: January 05, 2025, 06:36:03 pm »
If I remember correctly, in Delphi there is TFileOpenDialog with fdoPickFolders option, but I can't seem to find anything similar in Lazarus.
In Lazarus, this is "ofPickFolders". This is the same as in Delphi fdoPickFolders, and allows you to select folders ONLY.

Thanks, but I can't find the ofPickFolders option listed here:

https://lazarus-ccr.sourceforge.io/docs/lcl/dialogs/topenoptions.html

Bart

  • Hero Member
  • *****
  • Posts: 5510
    • Bart en Mariska's Webstek
Re: Dialog for selecting both files and directories
« Reply #4 on: January 05, 2025, 06:52:33 pm »
Thanks, but I can't find the ofPickFolders option listed here:
https://lazarus-ccr.sourceforge.io/docs/lcl/dialogs/topenoptions.html

It's in TOpenDialog.OptionsEx, but that's not documentend on that site (yet).
I don't think it's in fixes 3 (3.6 etc).
It will be in 4.0 (and should be in upcoming 4.0 RC2), it's a recent addition, exposing all Vista+ options for the dialog that were not in present in XP.

Code: Pascal  [Select][+][-]
  1.  TOpenOptionEx = (
  2.     ofHidePinnedPlaces,         //Windows Vista+ Hide items shown by default in the view's navigation pane.
  3.     ofForcePreviewPaneOn,       //Windows Vista+ Indicates to the Open dialog box that the preview pane should always be displayed (a NARG/NARL option IMHO)
  4.     ofStrictFileTypes,          //Windows Vista+ In the Save dialog, only allow the user to choose a file that has one of the file name extensions specified through Filter property
  5.     ofPickFolders,              //Windows Vista+ Turns the dialog into a TSelectDirectoryDialog
  6.     ofOkButtonNeedsInteraction, //Windows Vista+ The OK button will be disabled until the user navigates the view or edits the filename (if applicable).
  7.     ofForceFileSystem,          //Windows Vista+ Ensures that returned items are file system items
  8.     ofAllNonStorageItems        //Windows Vista+ Enables the user to choose any item in the Shell namespace, not just those with SFGAO_STREAM or SFAGO_FILESYSTEM attributes.
  9.                                 //               This flag cannot be combined with FOS_FORCEFILESYSTEM.
  10.     // Intentionally not supported: ofDefaultNoMiniMode, ofHideMruPlaces: these values are not supported as of Windows 7.
  11.   );
  12.   TOpenOptionsEx = set of TOpenOptionEx;

In Lazarus main, this has been extended with yet another flag.
At current they are all Windows specific, but other widgetset dependant flags (GTK, QT, Cocoa) could be implented as well.

Bart

TRon

  • Hero Member
  • *****
  • Posts: 3930
Re: Dialog for selecting both files and directories
« Reply #5 on: January 05, 2025, 06:58:36 pm »
It's in TOpenDialog.OptionsEx, but that's not documentend on that site (yet).
I don't think it's in fixes 3 (3.6 etc).
It will be in 4.0 (and should be in upcoming 4.0 RC2), it's a recent addition, exposing all Vista+ options for the dialog that were not in present in XP.

For (more) up to date docs see dsiders nextdoc site, for the extended dialog options in particular see here. Do note that all information listed is a work in progress (as is trunk).
I do not have to remember anything anymore thanks to total-recall.

 

TinyPortal © 2005-2018