LCL: TOpenDialog: do not set ofExtensionDifferent if multiple files are selected.

(Also don't bother setting it the result of Execute is False.)
Reason:
The behavour of ofExtensionDifferent is based upon the workings of Windows LPOPENFILENAME behaviour
This behaviour is completely irratic when multiple files are selected, it can be on or off given the same input
Delphi 7 seems to not include the ofExtensionDifferent flag if multiple files are selected, regardless of their extensions
(And nobody seems to bother anyway about this flag)
This commit is contained in:
Bart 2023-08-31 18:59:02 +02:00
parent 7b596989e8
commit a5b48a084d

View File

@ -352,9 +352,6 @@ begin
else else
AFilename:=AFilename+DefaultExt; AFilename:=AFilename+DefaultExt;
end; 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 //ofOverwritePrompt -> is done in the interface
if (ofPathMustExist in Options) if (ofPathMustExist in Options)
and (not DirPathExists(ExtractFileDir(AFilename))) then begin and (not DirPathExists(ExtractFileDir(AFilename))) then begin
@ -433,7 +430,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TOpenDialog.DoExecute: boolean; function TOpenDialog.DoExecute: boolean;
begin begin
Options := Options - [ofExtensionDifferent]; //clear, it'll be set by WS or in CheckFile Exclude(FOptions, ofExtensionDifferent);
Result:=inherited DoExecute; Result:=inherited DoExecute;
if not (ofNoResolveLinks in Options) then if not (ofNoResolveLinks in Options) then
ResolveLinks; ResolveLinks;
@ -445,6 +442,20 @@ begin
end; end;
if not Result then exit; if not Result then exit;
Result:=CheckAllFiles; Result:=CheckAllFiles;
//The behavour of ofExtensionDifferent is based upon the workings of Windows LPOPENFILENAME behaviour
//This behaviour is completely irratic when multiple files are selected, it can be on or off given the same input
//Delphi 7 seems to not include the ofExtensionDifferent flag if multiple files are selected, regardless of their extensions
//So, we unset the ofExtensionDifferent if multiple files are selected is set
if Result then
begin
if (Files.Count > 1) then
Exclude(FOptions, ofExtensionDifferent)
else
begin
if (DefaultExt <> '') and (CompareFileNames(DefaultExt,ExtractFileExt(Filename)) <> 0) then
Include(FOptions, ofExtensionDifferent);
end;
end;
end; end;
function TOpenDialog.DefaultTitle: string; function TOpenDialog.DefaultTitle: string;