[fpc-pascal] Assigning Interface method to event handler
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Wed May 25 10:41:24 CEST 2016
Hi,
Can I safely assign a method from an Interface reference to an event
handler. The code below works, but I'm not sure if it is safe to do so,
and allowed.
==================================
TTestApp = class(TObject)
private
rpt: TFPReportReport;
FReportFilter: IFPReportFilter; // can hold any export filter
...
constructor TTestApp.Create;
begin
rpt := TFPReportReport.Create(nil);
rpt.Author := 'Graeme Geldenhuys';
rpt.Title := 'FPReport Demo 4 - Frames and Fonts';
FReportFilter := TFPReportExportPDF.Create; // PDF output
//FReportFilter := TFPReportExportAggPas.Create; // PNG output
rpt.OnRenderReport := @FReportFilter.RenderReport;
...
end;
destructor TTestApp.Destroy;
begin
rpt.Free;
FReportFilter := nil;
inherited Destroy;
end;
==================================
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list