Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Report loaded from template not firing tppReport.preview form events

edited July 2008 in General
Please consider this code:

procedure TExRptExecute.ReportPreviewFormCreate(Sender: TObject);
begin
with (Sender as TppReport) do
PreviewForm.BorderIcons := [biSystemMenu];

end;

Procedure TExRptExecute.RunReport(Const ReportFile: String);
Begin;
If FileExists(ReportFile) then begin
Report.Template.FileName := ReportFile;
Report.Template.Load;
Report.PrintReport;
End;


End;

The PreviewFormCreate is correctly assigned to the event but never
gets fired after Report.PrintReport;

I also tried this:

procedure TExRptExecute.ReportAssignPreviewFormSettings(Sender:
TObject);
begin
with (Sender as TppReport) do
PreviewForm.BorderIcons := [biSystemMenu];

end;


Still does not work.

Is this a bug or am I doing somthing wrong. I need to disable the
minimize button on the preview form.

Using Delphi 2007 with ReportBuilder 10.8.

Thanks,

J. Michael Eubanks

--

Comments

  • edited July 2008

    Well.. it seems that the event must be reassigend after the
    template.load method, like this:

    Procedure TExRptExecute.RunReport(Const ReportFile: String);
    Begin;
    If FileExists(ReportFile) then begin
    Report.Template.FileName := ReportFile;
    Report.Template.Load;
    report.OnPreviewFormCreate := ReportPreviewFormCreate;
    Report.PrintReport;
    End;

    The event is correctly assigned at designtime.


    Michael

    --
  • edited July 2008
    the assigned event must be a published event for it to be saved to the
    template.

    When you save the template, if you save it as ASCII, you will see it in the
    report file.

    Ed Dressel

This discussion has been closed.