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

Preview and the RegenerateReport procedure

edited August 2003 in General
I have a radio box in my print preview with the option for landscape or
portrait. In the OnClick event is the following code...


if RadioGroup1.ItemIndex = 0 then
begin
ppViewer1.Report.PrinterSetup.Orientation := poLandscape;
ppViewer1.RegenerateReport;
end
else
begin
ppViewer1.Report.PrinterSetup.Orientation := poPortrait;
ppViewer1.RegenerateReport;
end;


In the BeforePrint of my report I have code which sets the field locations
based on whether the report is portrait or landscape, however, the
BeforePrint is not executed when a RegenerateReport is performed. Where is
the best/proper place to put such code in the report to ensure it is
executed when the report is regenerated.

Thanks,
Mark Greenhaw
One Domain, Inc.
xmark@onedomain.comx
(Remove the "x" before and after to email me)

Comments

  • edited August 2003
    Hi Mark,

    RegenerateReport is not going to cut it. It simply resets the device and
    publisher and starts making more page requests. The engine is not reset and
    the PrintToDevice call on the producer (report) is not called. Here is an
    example that works by using a custom preview plugin to change the
    orientation. Notice the BeforePrint event of the main report cahnges the
    shape width based on its orientation:

    Created with RB 7.03 and D6:
    http://www.digital-metaphors.com/tips/ToggleOrientationPlugin.zip


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2003
    Thanks Jim,

    I had put the code in the ppHeaderBand1BeforeGenerate and everything seemed
    to be working great until I switched to Portrait from Landscape and then
    started moving through the pages. There should have been more pages than the
    Lanscape and it went into a loop. I'll look at the code and see if I can
    implement it in our custom previewer.

    Thanks again,
    Mark Greenhaw
    One Domain, Inc.
    xmark@onedomain.comx
    (Remove the "x" before and after to email me)


  • edited August 2003
    Hi Mark,

    If the report is reset (page cache cleared), the devices are reset, and the
    engine is reset and the layout changes, then the next time
    Report.PrintToDevices is called it should generate and calculate the correct
    pagination for the new layout to the screen device. You'll have to change
    the layout before the report starts printing. Try using the
    Report.BeforePrint event instead of the Header BeforeGenerate event.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.