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

Can't access preview form create event

edited June 2002 in General
I have a report explorer, report designer, data dictionary and report hooked
up on a form (with table and item pipelines etc). This is all in a
datamodule. The report component is named Report.

On the report PreviewFormCreate event handler I have the following code:

procedure TDataModuleReportExplorer.ReportPreviewFormCreate(
Sender: TObject);

var
lReport: TppReport;

begin

lReport := TppReport(Sender);

lReport.PreviewForm.WindowState := wsMaximized;
TppViewer(lReport.PreviewForm.Viewer).ZoomSetting := zsPageWidth;

end;

The problem is that it does not seem to run this event - I put breakpoints
in the body of this handler and it does not seem to reach them.

Why wouldn't the preview form create event be run?

Thanks,

Lauchlan M.

Comments

  • edited June 2002
    Hi Lauchlan,

    because you are using report templates. The events are assigned as stored in
    the template. After loading a template you have to re-assign all events, see
    the 'Templates' section in the tech-tips news group (especially 'Article:
    Troubleshooting Lost Event Handlers').

    regards,
    Chris Ueberall;

  • edited June 2002
    > because you are using report templates. The events are assigned as stored
    in
    see

    Chris,

    in the datamodule class declaration I have

    private
    { Private declarations }
    procedure LoadEndEvent(Sender: TObject);
    procedure PreviewFormCreateEvent(Sender: TObject);

    I also have

    procedure TDataModuleReportExplorer.LoadEndEvent(Sender: TObject);
    begin
    Report.OnPreviewFormCreate := PreviewFormCreateEvent;
    end;

    procedure TDataModuleReportExplorer.PreviewFormCreateEvent(Sender: TObject);
    begin
    Report.PreviewForm.WindowState := wsMaximized;
    TppViewer(Report.PreviewForm.Viewer).ZoomSetting := zsPageWidth;
    end;

    procedure TDataModuleReportExplorer.ReportDesignerCreateReport(
    Sender: TObject; const aDataName: String; var aReport: TObject);
    begin
    Report.Template.FileName := 'iCARnetHeader.rtm';
    Report.Template.LoadFromFile;
    end;

    I would have thought that the LoadEndEvent handler would reassign the
    PreviewFormCreate handler.

    Any other suggestions appreciated.

    Lauchlan M.
  • edited June 2002
    Hi Lauchlan,

    yes, your 'LoadEndEvent' method should do it, for the case it is assigned to
    Report.Template's 'OnLoadEnd' event.
    You have to assign the event handler in code (not published).

    regards,
    Chris Ueberall;

This discussion has been closed.