From 7d4a36a290d0ca71c05a9a5f44661335c7b94055 Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Wed, 30 Aug 2023 23:23:17 +0200 Subject: [PATCH] LCL: TOpenDialog: set ofExtensionDifferent if (DefaultExt <> '') and (Extension <> DefExt) for all WS. Our docs about ofExtensionDifferent wrongfully states: "Allows a file name with an extension which does not match the filters or default extension in a file dialog." This is not how Delphi defines it, and also not how it's implemented in pre-Vista dialogs (using OPENFILE structure, the OS sets the corresponding flag). (Since there have been no bugreports about this, it's doubtfull anybody cares, but nevertheless...) --- lcl/include/filedialog.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lcl/include/filedialog.inc b/lcl/include/filedialog.inc index 24ee1fb16d..ad21a05e08 100644 --- a/lcl/include/filedialog.inc +++ b/lcl/include/filedialog.inc @@ -352,6 +352,9 @@ begin else AFilename:=AFilename+DefaultExt; end; + if (not {already} (ofExtensionDifferent in FOptions)) and (DefaultExt <> '') + and (CompareFileNames(DefaultExt,ExtractFileExt(AFilename)) <> 0) then + Include(FOptions, ofExtensionDifferent); //ofOverwritePrompt -> is done in the interface if (ofPathMustExist in Options) and (not DirPathExists(ExtractFileDir(AFilename))) then begin @@ -430,6 +433,7 @@ end; ------------------------------------------------------------------------------} function TOpenDialog.DoExecute: boolean; begin + Options := Options - [ofExtensionDifferent]; //clear, it'll be set by WS or in CheckFile Result:=inherited DoExecute; if not (ofNoResolveLinks in Options) then ResolveLinks;