Class TQRStdPreviewDialog (unit amPrvPrt)

Inherits from

TComponent

--------------------------------------} {TQRStdPreviewDialog

Constructors


Constructor Create(AOwner: TComponent);

------------------------------------------------------------------------ TQRSTDPREVIEW DIALOG ------------------------------------------------------------------------} {------------------------------------------------------------------------ Destructor TQRStdPreviewDialog.


Functions

Destructor Destroy;

------------------------------------------------------------------------} {Destructor TQRStdPreviewDialog.

procedure NewFormCloseQuery(Sender: TObject; var CanClose: Boolean);

------------------------------------------------------------------------} { TQRStdPreviewDialog.

procedure NewPageAvailable(Sender: TObject; PageNum: Integer);

------------------------------------------------------------------------} { TQRStdPreviewDialog.

Procedure NewPreview(Sender: TObject);

------------------------------------------------------------------------} { TQRStdPreviewDialog.

Procedure CloseDialog;

------------------------------------------------------------------------} {TQRStdPreviewDialog.

Procedure EnableButtons(Enable: Boolean);

------------------------------------------------------------------------} { TQRStdPreviewDialog.

Function GetaQuickrep: TQuickrep;

------------------------------------------------------------------------} { TQRStdPreviewDialog.

Procedure PrintPreview(Sender: TObject);

------------------------------------------------------------------------} {TQRStdPreviewDialog.

Procedure RefreshPreview;

------------------------------------------------------------------------} {TQRStdPreviewDialog.

Procedure SetaQuickrep(Value: TQuickrep);

------------------------------------------------------------------------} { TQRStdPreviewDialog.

Procedure SetSelectPrinterDialog(Value: Boolean);

------------------------------------------------------------------------} {Procedure TQRStdPreviewDialog.

Procedure SetShowPrintDialog(Value: Boolean);

------------------------------------------------------------------------} {Procedure TQRStdPreviewDialog.

Procedure ShowDialog(Sender: TObject);

------------------------------------------------------------------------} {TQRStdPreviewDialog.

Properties

property aQuickrep : TQuickrep


property Copyright : String


property SelectPrinterDialog : Boolean


property ShowPrintDialog : Boolean


property Version : String


Events

Variables

QRPreviewForm : TQRStandardPreview;


RefreshRequest : Boolean;


amPrinter : TamPrinter;


faQuickrep : TQuickrep;


fCopyright : String;


fDummy : String;


fSelectprinterDialog : Boolean;


fShowPrintDialog : Boolean;


fVersion : String;



Constructors


Constructor Create(AOwner: TComponent);

------------------------------------------------------------------------ TQRSTDPREVIEW DIALOG ------------------------------------------------------------------------} {------------------------------------------------------------------------ Destructor TQRStdPreviewDialog.Create; Purpose: Standard and link aQuickrep automatically at design time. Search the Owner Components if there is one Quickrep Component and link to it. If more then one available, skip them all. ------------------------------------------------------------------------


Functions


Destructor Destroy;

------------------------------------------------------------------------} {Destructor TQRStdPreviewDialog.Destroy; Purpose: Unlink aQuickrep and Close (Destroy) PreviewForm if existing Destroy the amPrinter Object} {------------------------------------------------------------------------


procedure NewFormCloseQuery(Sender: TObject; var CanClose: Boolean);

------------------------------------------------------------------------} { TQRStdPreviewDialog.NewFormCloseQuery(Sender: TObject); Purpose: Will be linked to the PreviewForm.OnFormCloseQuery event. Edit further code if needed. {------------------------------------------------------------------------


procedure NewPageAvailable(Sender: TObject; PageNum: Integer);

------------------------------------------------------------------------} { TQRStdPreviewDialog.NewPageAvailable(Sender: TObject); Purpose: Will be linked to the Valid QRPreview.OnPageAvailable event. Enables or diables PrintButtons depending on QRPrinter.State. Sets amPrinter.aQrPrinter if finished. Results in some Init of the amPrinter. Edit further code if needed. {------------------------------------------------------------------------


Procedure NewPreview(Sender: TObject);

------------------------------------------------------------------------} { TQRStdPreviewDialog.NewPreview(Sender: TObject); Purpose: Will be linked to the Quickreport NewPreview event by setting aQuickrep. Edit further code if needed. {------------------------------------------------------------------------


Procedure CloseDialog;

------------------------------------------------------------------------} {TQRStdPreviewDialog.CloseDialog; Purpose: Close the DialogForm if still existing; {------------------------------------------------------------------------


Procedure EnableButtons(Enable: Boolean);

------------------------------------------------------------------------} { TQRStdPreviewDialog.EnableButtons(Enable: Boolean) Purpose: Enables/Disables Buttons which to access would be no good Idea while preparing of Preview by Quickrep {------------------------------------------------------------------------


Function GetaQuickrep: TQuickrep;

------------------------------------------------------------------------} { TQRStdPreviewDialog.GetaQuickrep: TQuickrep; Purpose: Standard property setting. Edit more code if needed. {------------------------------------------------------------------------


Procedure PrintPreview(Sender: TObject);

------------------------------------------------------------------------} {TQRStdPreviewDialog.PrintPreview(Sender: TObject) Purpose: The main thing why i wrote this sample. If printButton is pressed a PrintDialog will be created. Printer values may be set and will result in a new Preview or printing. Unfortunately there are a few problems with Quickreport printing. 1. QR2.0: If use choose Quickrep for Printing, you may select certain pages to be print, but e.g. if you only want to print the first page, it will print 2 pages instead. Though the second page will be empty, it will cause the printer to waste one sheet of paper. Beside this, quickrep will prepare the job onesmore, although it was prepared befor to show the preview. 2. The idea to use QRPreviewForm.QRPreview.QRPrinter.Print instead doesn't lead to preparing again, but there is no way to print only selected pages. It will print the whole report and - why not - a empty sheet over and above. prPageNums will not work correct since Qusoft would have to change source code of qrprntr.pas (only one Line of code, which qusoft did comment out !!!) and/or quickrpt.pas. I wrote them a message, but never received a response, so i don't know for what reasons they acted in this way. So, i decided to take an other way to work around: We have there after previewing all the data we need. All we have to do, is to put TGraphic (TMetafile) from the QRPrinter pages to a new printer objects canvas - and just print; that's all. For this purpose i derived a simple object which encapsulates the TPrinter (Delphi not Quickreport) and QRPrinter class: TamPrinter. {------------------------------------------------------------------------


Procedure RefreshPreview;

------------------------------------------------------------------------} {TQRStdPreviewDialog.RefreshPreview Purpose: This is one way to get a new preview without creating a new Previewform after Quickrep values have changed. e.g. the page orientation or size. } {------------------------------------------------------------------------


Procedure SetaQuickrep(Value: TQuickrep);

------------------------------------------------------------------------} { TQRStdPreviewDialog.SetaQuickrep(Value: TQuickrep); Purpose: 1. unlink previous OnPreview eventhandling (important if changing the Value at Runtime) 2. Set the (new) value to aQuickrep property Eventhandling set by the Objectinspector will not be saved nor restored !! So, edit TQRStdPreviewDialog.NewPreview(Sender: TObject)if nessesary. {------------------------------------------------------------------------


Procedure SetSelectPrinterDialog(Value: Boolean);

------------------------------------------------------------------------} {Procedure TQRStdPreviewDialog.SetSelectPrinterDialog(Value: Boolean); Purpose: Default and set the amPrinter Property} {------------------------------------------------------------------------


Procedure SetShowPrintDialog(Value: Boolean);

------------------------------------------------------------------------} {Procedure TQRStdPreviewDialog.SetShowPrintDialog(Value: Boolean); Purpose: Default and set the amPrinter Property} {------------------------------------------------------------------------


Procedure ShowDialog(Sender: TObject);

------------------------------------------------------------------------} {TQRStdPreviewDialog.ShowDialog(Sender: TObject) purpose: Creates the StandardPreview and sets some Values; also links new Eventhandlers, at last shows the Form. } {------------------------------------------------------------------------


Properties


property aQuickrep : TQuickrep


property Copyright : String


property SelectPrinterDialog : Boolean


property ShowPrintDialog : Boolean


property Version : String


Events


Variables


QRPreviewForm : TQRStandardPreview;


RefreshRequest : Boolean;


amPrinter : TamPrinter;


faQuickrep : TQuickrep;


fCopyright : String;


fDummy : String;


fSelectprinterDialog : Boolean;


fShowPrintDialog : Boolean;


fVersion : String;