I am porting a project to FMX (from VCL). I use a TSaveDialog with Filter for the file extensions, but when I change the extension the 'OnTypeChange' event does'nt fire, but the 'OnShow' event fires !
I tried TOpenDialog with the same problem.
Some informations :
- Delphi Pro 10.3.1 (I tried Delphi 10.3.3)
- Event 'OnFolderChange' does'nt fire.
- Events 'OnClose' and 'OnShow' are OK.
Any idea ? Is there any option I missed ? Or a known bug ? My test code : just a Form with a TButton and a TSaveDialog whith some code in the events to show if they are fired.
unit Unit1;
interface
uses
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Controls.Presentation,
FMX.StdCtrls, System.Classes;
type
TForm1 = class(TForm)
SaveDialog1: TSaveDialog;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure SaveDialog1FolderChange(Sender: TObject);
procedure SaveDialog1TypeChange(Sender: TObject);
procedure SaveDialog1Close(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.SaveDialog1Close(Sender: TObject);
begin
Self.Caption := Self.Caption ', Close';
end;
procedure TForm1.SaveDialog1FolderChange(Sender: TObject);
begin
Self.Caption := Self.Caption ', Folder';
end;
procedure TForm1.SaveDialog1TypeChange(Sender: TObject);
begin
Self.Caption := Self.Caption ', Change';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Self.Caption := 'Start';
SaveDialog1.Filter := 'Applications (*.exe)|*.EXE|Text files (*.txt)|*.TXT';
SaveDialog1.Execute;
end;
end.
Thx
CodePudding user response:
Although the OnFolderChange
and OnTypeChange
events are published and assignable in the TSaveDialog
's Object Inspector these do nothing at all.
It is possible though to make these events work like in VCL by copying the source file FMX.Dialogs.Win.pas
to your project folder and adding the relevant missing bits from the Vcl.Dialogs.pas
source file, which include but not limited to:
- References to
FolderChange
andTypeChange
inTCustomFileDialog
class. - Procedures
OnFolderChangeEvent
andOnTypeChangeEvent
inTFileDialogWrapper
class. - The whole
TFileDialogEvents
class.
Although these changes were tested with Delphi 10.3.3 the solution should be similar for Delphi 10.3.1 and even more recent versions as this unit hasn't changed much along time.