diff --git a/lcl/dialogs.pp b/lcl/dialogs.pp index bfbde88f0b..6e0c1e2137 100644 --- a/lcl/dialogs.pp +++ b/lcl/dialogs.pp @@ -192,7 +192,7 @@ type ofShowHelp, // show a help button ofNoValidate, ofAllowMultiSelect,// allow multiselection - ofExtensionDifferent, + ofExtensionDifferent, // set after the dialog is executed (so, don't set it yourself) if DefaultExt <> '' and Extension <> DefaultExt ofPathMustExist, // shows an error message if selected path does not exist ofFileMustExist, // shows an error message if selected file does not exist ofCreatePrompt, @@ -212,6 +212,24 @@ type ofAutoPreview // details are OS and interface dependent ); TOpenOptions = set of TOpenOption; + + // WS specific options that cannot be (more or less) mapped to the standard TOpenOptions + // Currently just Windows Vista+ (IFileDialog) options + TOpenOptionEx = ( + ofHidePinnedPlaces, //Windows Vista+ Hide items shown by default in the view's navigation pane. + ofForcePreviewPaneOn, //Windows Vista+ Indicates to the Open dialog box that the preview pane should always be displayed (a NARG/NARL option IMHO) + 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 + ofPickFolders, //Windows Vista+ Turns the dialog into a TSelectDirectoryDialog + ofOkButtonNeedsInteraction, //Windows Vista+ The OK button will be disabled until the user navigates the view or edits the filename (if applicable). + ofForceFileSystem, //Windows Vista+ Ensures that returned items are file system items + ofAllNonStorageItems //Windows Vista+ Enables the user to choose any item in the Shell namespace, not just those with SFGAO_STREAM or SFAGO_FILESYSTEM attributes. + // This flag cannot be combined with FOS_FORCEFILESYSTEM. + // Intentionally not supported: ofDefaultNoMiniMode, ofHideMruPlaces: these values are not supported as of Windows 7. + ); + TOpenOptionsEx = set of TOpenOptionEx; + //Old Delpi OpenOptionEx, mapped to ofHidePinnedPlaces +const + ofExNoPlacesBar = ofHidePinnedPlaces; const DefaultOpenDialogOptions = [ofEnableSizing, ofViewDetail]; @@ -223,6 +241,7 @@ type FOnFolderChange: TNotifyEvent; FOnSelectionChange: TNotifyEvent; FOptions: TOpenOptions; + FOptionsEx: TOpenOptionsEx; FLastSelectionChangeFilename: string; protected class procedure WSRegisterClass; override; @@ -240,6 +259,7 @@ type procedure IntfSetOption(const AOption: TOpenOption; const AValue: Boolean); published property Options: TOpenOptions read FOptions write FOptions default DefaultOpenDialogOptions; + property OptionsEx: TOpenOptionsEx read FOptionsEx write FOptionsEx default []; property OnFolderChange: TNotifyEvent read FOnFolderChange write FOnFolderChange; property OnSelectionChange: TNotifyEvent read FOnSelectionChange write FOnSelectionChange; end; diff --git a/lcl/include/filedialog.inc b/lcl/include/filedialog.inc index de77078793..24ee1fb16d 100644 --- a/lcl/include/filedialog.inc +++ b/lcl/include/filedialog.inc @@ -460,6 +460,7 @@ begin inherited Create(TheOwner); fCompStyle:=csOpenFileDialog; FOptions := DefaultOpenDialogOptions; + FOptionsEx := []; end; procedure TOpenDialog.DoCanClose(var CanClose: Boolean); diff --git a/lcl/interfaces/win32/win32wsdialogs.pp b/lcl/interfaces/win32/win32wsdialogs.pp index adfb87023c..80cc5f94b4 100644 --- a/lcl/interfaces/win32/win32wsdialogs.pp +++ b/lcl/interfaces/win32/win32wsdialogs.pp @@ -77,7 +77,7 @@ type TWin32WSOpenDialog = class(TWSOpenDialog) public - class function GetVistaOptions(Options: TOpenOptions; SelectFolder: Boolean): FileOpenDialogOptions; + class function GetVistaOptions(Options: TOpenOptions; OptionsEx: TOpenOptionsEx; SelectFolder: Boolean): FileOpenDialogOptions; class procedure SetupVistaFileDialog(ADialog: IFileDialog; const AOpenDialog: TOpenDialog); class function ProcessVistaDialogResult(ADialog: IFileDialog; const AOpenDialog: TOpenDialog): HResult; @@ -815,7 +815,7 @@ begin ParsedFilter.Free; end; - ADialog.SetOptions(GetVistaOptions(AOpenDialog.Options, AOpenDialog is TSelectDirectoryDialog)); + ADialog.SetOptions(GetVistaOptions(AOpenDialog.Options, AOpenDialog.OptionsEx, AOpenDialog is TSelectDirectoryDialog)); end; class function TWin32WSOpenDialog.GetFileName(ShellItem: IShellItem): String; @@ -832,20 +832,14 @@ begin end; class function TWin32WSOpenDialog.GetVistaOptions(Options: TOpenOptions; - SelectFolder: Boolean): FileOpenDialogOptions; -{ non-used flags -FOS_FORCEFILESYSTEM -FOS_ALLNONSTORAGEITEMS -FOS_HIDEMRUPLACES -FOS_HIDEPINNEDPLACES -FOS_DEFAULTNOMINIMODE -FOS_FORCEPREVIEWPANEON} - + OptionsEx: TOpenOptionsEx; SelectFolder: Boolean): FileOpenDialogOptions; +const + FOS_OKBUTTONNEEDSINTERACTION = $200000; //not yet in ShlObj begin Result := 0; if ofAllowMultiSelect in Options then Result := Result or FOS_ALLOWMULTISELECT; if ofCreatePrompt in Options then Result := Result or FOS_CREATEPROMPT; - if ofExtensionDifferent in Options then Result := Result or FOS_STRICTFILETYPES; + //if ofExtensionDifferent in Options then Result := Result or FOS_STRICTFILETYPES; //that's just wrong if ofFileMustExist in Options then Result := Result or FOS_FILEMUSTEXIST; if ofNoChangeDir in Options then Result := Result or FOS_NOCHANGEDIR; if ofNoDereferenceLinks in Options then Result := Result or FOS_NODEREFERENCELINKS; @@ -856,7 +850,7 @@ begin if ofPathMustExist in Options then Result := Result or FOS_PATHMUSTEXIST; if ofShareAware in Options then Result := Result or FOS_SHAREAWARE; if ofDontAddToRecent in Options then Result := Result or FOS_DONTADDTORECENT; - if SelectFolder then Result := Result or FOS_PICKFOLDERS; + if SelectFolder or (ofPickFolders in OptionsEx) then Result := Result or FOS_PICKFOLDERS; if ofForceShowHidden in Options then Result := Result or FOS_FORCESHOWHIDDEN; { unavailable options: ofHideReadOnly @@ -866,6 +860,16 @@ begin ofReadOnly ofShowHelp } + { non-used flags: + FOS_HIDEMRUPLACES, FOS_DEFAULTNOMINIMODE: both of them are unsupported as of Win7 + FOS_SUPPORTSTREAMABLEITEMS + } + if ofHidePinnedPlaces in OptionsEx then Result := Result or FOS_HIDEPINNEDPLACES; + if ofForcePreviewPaneOn in OptionsEx then Result := Result or FOS_FORCEPREVIEWPANEON; + if ofStrictFileTypes in OptionsEx then Result := Result or FOS_STRICTFILETYPES; + if ofOkButtonNeedsInteraction in OptionsEx then Result := Result or FOS_OKBUTTONNEEDSINTERACTION; + if ofForceFileSystem in OptionsEx then Result := Result or FOS_FORCEFILESYSTEM; + if ofAllNonStorageItems in OptionsEx then Result := Result or FOS_ALLNONSTORAGEITEMS; end; class function TWin32WSOpenDialog.ProcessVistaDialogResult(ADialog: IFileDialog; const AOpenDialog: TOpenDialog): HResult;