Question
“How do I customize the Open/Save To File dialogs?”
Solution
The Report.Template property has an OnCreateDialog event.
The public event is defined as:
property OnCreateDialog: TppDialogEvent read FOnCreateDialog write FOnCreateDialog;
And the TppDialogEvent type is defined as:
TppDialogEvent = procedure(Sender: TObject; aDialog: TObject) of object;
You can customize the TOpenDialog and TSaveDialog properties by using this
event to gain access to the Dialog object.
Sample Delphi code:
uses ppTmplat; TMyForm = class(TForm) public procedure myCreateDialogEvent(Sender: TObject; aDialog: TObject); end; procedure TMyForm.FormCreate(Sender: TObject); begin {assign the event-handler} ppReport1.Template.OnCreateDialog := myCreateDialogEvent; end; procedure TMyForm.myCreateDialogEvent(Sender: TObject; aDialog: TObject); var lOpenDialog: TOpenDialog; lSaveDialog: TSaveDialog; begin {get access to the dialog and set properties} if aDialog is TOpenDialog then begin lOpenDialog := TOpenDialog(aDialog); lOpenDialog.InitiaDir := 'c:\myReports\'; end else if aDialog is TSaveDialog then begin lSaveDialog := TSaveDialog(aDialog); lSaveDialog.InitiaDir := 'c:\myReports\'; end;