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

TppPrintPreview Changed Again

edited June 2002 in General
Hi:

Almost every new release of Report Builder breaks my Previewer Code.
I have a ancestor form which implements a customized previwer for a
report. I simply drop a ppReport on the form and in the form's
OnCreate call OpenReport(ppReport1). I have listed the OpenReport
current implementation at the end of this message. Two problems need
to be resolved:

1) The previewer displays and everything works normally except that
nothing happens when the print button is pressed. When this started
happening in an earlier release of ReportBuilder, I added the
following line of code:
TppViewer(DefaultPreviewer.Viewer).ScreenDevice.Active := True;

Now even with this line, nothing is happening when the print button is
pressed. What needs to be done to fix this?


2) In the past I was able to use to make the Close button invisible
to the user: DefaultPreviewer.spbPreviewClose.Visible := False;
Since this no longer works, I chose to leave the button visible and
cause it to close the form. Here is the code:
...
DefaultPreviewer.OnCloseQuery := PreviewerCloseQuery;
...
procedure TbfReport.PreviewerCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
Self.Close;
end;

This works but is there anything I need to do different to prevent any
problems with Report Builder when the close button is pressed?


Thanks, Sidney

------------------- OPEN REPORT PROCEDURE --------------
procedure TbfReport.OpenReport(Report: TppReport);
begin
Screen.Cursor := crHourGlass;
try
if ReportIsOpen then
Report.PrintToDevices
else
begin
DefaultPreviewer := TppPrintPreview.Create(Self);
DefaultPreviewer.Visible := False;
DefaultPreviewer.Parent := DefaultPreviewerPanel;
DefaultPreviewer.BorderStyle := bsNone;
DefaultPreviewer.Align := alClient;
DefaultPreviewer.Report := Report;
DefaultPreviewer.OnCloseQuery := PreviewerCloseQuery;
TppViewer(DefaultPreviewer.Viewer).Report := Report;
TppViewer(DefaultPreviewer.Viewer).ZoomSetting := zsPageWidth;
TppViewer(DefaultPreviewer.Viewer).ScreenDevice.Active := True;
if UpperCase(Report.PrinterSetup.DocumentName) = 'REPORT' then
Report.PrinterSetup.DocumentName := Self.Caption;
Report.PrintToDevices;
DefaultPreviewer.Visible := True;
ReportIsOpen := True;
end;
finally
Screen.Cursor := crDefault;
end;
end;

Comments

This discussion has been closed.