Home > Software engineering >  Include multi-selection option in file-open-dialog
Include multi-selection option in file-open-dialog

Time:06-11

To allow multiselection in a file-open-dialog and to avoid this long expression:

OpenDialogSourceFiles.Options := OpenDialogSourceFiles.Options   [Vcl.Dialogs.fdoAllowMultiSelect]; // works

I tried to use the shorter Include function:

System.Include(OpenDialogSourceFiles.Options, Vcl.Dialogs.fdoAllowMultiSelect);  // error

However, the compiler marks this as erroneous.

CodePudding user response:

This is by design. The Include procedure requires a variable as its first argument (it is a var parameter, essentially, even though the procedure is implemented by compiler magic), but TFileOpenDialog.Options is a property.

Hence you must use the verbose alternative. There's nothing you can do about it.

The same thing applies to Inc and TComponent.Tag, for instance.

(But you can write fdoAllowMultiSelect instead of Vcl.Dialogs.fdoAllowMultiSelect, Include instead of System.Include, etc. to make it a bit less verbose.)

  • Related