TppPrintPreview Changed Again
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;
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;
This discussion has been closed.
Comments
http://www.digital-metaphors.com/tips/myCloseButtonPreviewPlugin.zip
Using the previous demo's appraoch to accessing the speed buttons, you can
access the print button as well. The print button should work by default.
Here is the code which is called when you press print from the current
preview.
{---------------------------------------------------------------------------
---}
{ TppCustomPreview.Print }
procedure TppCustomPreview.Print;
begin
if FReport = nil then Exit;
if (Assigned(BeforePrint)) then BeforePrint(Self);
try
FViewer.Print;
finally
if (Assigned(AfterPrint)) then AfterPrint(Self);
end;
end; {procedure, Print}
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
you call Viewer.Print.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
thread.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com