AddEventHandler(Events: IPrxReportUserEvents): Integer;
Events. Event handler.
The AddEventHandler method adds an event handler into the report. The method returns index of the event handler. This method is an alternative to the IPrxAssemblies.EventsClass property.
To execute the example, create a unit (see below unit text), then create a regular report, for which determine the created unit as an event handler (specify the EventsClass class). Create two hyperlinks in the report: the first one executes the AddEventHandler procedure, the second one executes the RemoveEventHandler procedure.
Var i: Integer;
Class EventsClass: ReportEvents
//event after report export
Public Sub OnAfterExportReport(Report: IPrxReport);
Begin
WinApplication.InformationBox("Report export «" + Report.Name + "» complete");
End Sub OnAfterExportReport;
End Class EventsClass;
Class MyEventsClass: ReportEvents
//event before saving report
Public Sub OnBeforeSaveReport(Report: IPrxReport; Var Cancel: Boolean);
Begin
If Not WinApplication.ConfirmationBox("Save data?") Then
Cancel := True;
End If;
End Sub OnBeforeSaveReport;
End Class MyEventsClass;
Public Sub AddEventHandler;
Var
Ev: MyEventsClass;
Begin
Ev := New MyEventsClass.Create;
i := PrxReport.ActiveReport.AddEventHandler((Ev As IPrxReportUserEvents));
End Sub AddEventHandler;
Public Sub RemoveEventHandler;
Begin
PrxReport.ActiveReport.RemoveEventHandler(i);
End Sub RemoveEventHandler;
After clicking the hyperlink that executes the AddEventHandler procedure, the report will use the MyEventsClass handler. To check them, modify the report, save the changes and export data. After clicking the hyperlink that executes the RemoveEventHandler procedure the earlier added event handler is removed.
See also: