Dialogs: don't call TOpenDialog.OnCanClose if ofOldStyleDialog in Options (Delphi compatibility). Part of Issue #0021147.

git-svn-id: trunk@52788 -
This commit is contained in:
bart 2016-08-07 23:21:07 +00:00
parent 6e5cf2da5a
commit 8a444a31ef
2 changed files with 14 additions and 1 deletions

View File

@ -199,6 +199,7 @@ type
function DefaultTitle: string; override;
public
constructor Create(TheOwner: TComponent); override;
procedure DoCanClose(var CanClose: Boolean); override;
procedure DoFolderChange; virtual;
procedure DoSelectionChange; virtual;
procedure IntfSetOption(const AOption: TOpenOption; const AValue: Boolean);

View File

@ -37,7 +37,7 @@ end;
procedure TFileDialog.DoCanClose(var CanClose: Boolean);
begin
debugln(['TFileDialog.DoCanClose: FUserChoice = ',ModalResultStr[FUserChoice],' HandleAllocated=',HandleAllocated]);
//debugln(['TFileDialog.DoCanClose: FUserChoice = ',ModalResultStr[FUserChoice],' HandleAllocated=',HandleAllocated]);
//Only call OnCanClose if user did not cancel the dialog, see:
//http://docwiki.embarcadero.com/Libraries/Berlin/en/Vcl.Dialogs.TOpenDialog_Events
if (FUserChoice = mrOK) then
@ -432,6 +432,18 @@ begin
FOptions := DefaultOpenDialogOptions;
end;
procedure TOpenDialog.DoCanClose(var CanClose: Boolean);
begin
//Delphi never calls OnCanClose in this case
if not (ofOldStyleDialog in Options) then
inherited DoCanClose(CanClose)
else
begin
FCanCloseCalled := True;
CanClose := True;
end;
end;
procedure TOpenDialog.DoFolderChange;
begin
if Assigned(OnFolderChange) then OnFolderChange(Self);