RemoveEventHandler(Cookie: Integer);
Cookie - index of event handler.
The RemoveEventHandler method removes event handler from the report.
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, change the report, save changes and export. After clicking the hyperlink that executes the RemoveEventHandler procedure the previously added event handler is deleted.
See also: