user1580348
user1580348

Reputation: 6051

Include multi-selection option in file-open-dialog

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.

Upvotes: 2

Views: 1066

Answers (1)

Andreas Rejbrand
Andreas Rejbrand

Reputation: 108948

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.)

Upvotes: 2

Related Questions