Question
“How can I implement custom processing when reports are loaded/saved?”
Solution
The following example shows how to implement the Designer OnOpenDoc and OnSaveDoc events to either override or augment the built-in save/load logic. When the OnCustomOpenDoc, OnCustomSaveDoc events are assigned, the report designer will not save or load any reports – it will instead fire the events and your event-handler code will be responsible for taking appropriate action.
Download: DesignerCustomOpenSaveDoc.zip
Sample Delphi code:
procedure TForm1.ppDesigner1CustomOpenDoc(Sender: TObject);
begin
// This example displays a message and then loads the template
// Template.Decription is a convenience property that return either
// - Template.FileName for a file based template
// - Template.DatabaseSettings.Name for a database template
ShowMessage('CustomOpenDoc: ' + ppReport1.Template.Description);
// Template.Load is a convenience method that calls either
// - Template.LoadFromFile for a file based template
// - Template.LoadFromDatabase for a database template
ppReport1.Template.Load; // could do something different here
end;
procedure TForm1.ppDesigner1CustomSaveDoc(Sender: TObject);
begin
// This example displays a message and then saves the template
// Template.Decription is a property that return either
// - Template.FileName for a file based template
// - Template.DatabaseSettings.Name for a database template
ShowMessage('CustomSaveDoc: ' + ppReport1.Template.Description);
// Template.Save is a convenience method that calls either
// - Template.SaveFromFile for a file based template
// - Template.SaveFromDatabase for a database template
ppReport1.Template.Save; // could do something different here
end;