@@ -71,6 +71,7 @@ TfrmExtFileDialog = class(TExtForm)
7171 procedure SetInitialDir (const AValue: String);
7272 procedure SetFilterIndex (AValue: Integer);
7373 function GetPathPartAt (X: Integer): String;
74+ procedure SetOptions (AValue: TOpenOptions);
7475 public
7576 property OnTypeChange: TNotifyEvent read FOnTypeChange write FOnTypeChange;
7677 property Title: String write SetTitle;
@@ -79,7 +80,7 @@ TfrmExtFileDialog = class(TExtForm)
7980 property FileName: String read GetFileName write SetFileName;
8081 property InitialDir: String read FInitialDir write SetInitialDir;
8182 property DefaultExt: String read FDefaultExt write FDefaultExt;
82- property Options: TOpenOptions read FOptions write FOptions ;
83+ property Options: TOpenOptions read FOptions write SetOptions ;
8384 property Files: TStringList read FFiles;
8485 property FilterIndex: Integer read FFilterIndex write SetFilterIndex;
8586 end ;
@@ -157,7 +158,6 @@ procedure TfrmExtFileDialog.FormShow(Sender: TObject);
157158 LineBreakIndexInt: Integer;
158159 PreviousDir: String;
159160begin
160- ShellListView.MultiSelect := ofAllowMultiSelect in FOptions;
161161 PreviousDir := AppSettings.ReadString(asFileDialogPreviousDir);
162162 if not FInitialDir.IsEmpty then
163163 SetInitialDir(FInitialDir)
@@ -237,6 +237,17 @@ function TfrmExtFileDialog.GetPathPartAt(X: Integer): String;
237237 end ;
238238end ;
239239
240+ procedure TfrmExtFileDialog.SetOptions (AValue: TOpenOptions);
241+ begin
242+ if FOptions = AValue then
243+ Exit;
244+ FOptions := AValue;
245+ if (ofAllowMultiSelect in FOptions) <> ShellListView.MultiSelect then begin
246+ // This would crash if we would do it in FormShow. See issue #2410
247+ ShellListView.MultiSelect := ofAllowMultiSelect in FOptions;
248+ end ;
249+ end ;
250+
240251procedure TfrmExtFileDialog.lblPathMouseMove (Sender: TObject;
241252 Shift: TShiftState; X, Y: Integer);
242253begin
0 commit comments