01/10/2000 Copyright © 2000
Graham Murt
![]()
E-mail: gmurt@freeuk.com
Website: http://www.murtsoft.com
ώ
Delphi
3
ώ
Delphi
4
ώ Delphi 5
Introduction......................................................................................................................................................................... Page
1
Properties, Methods and
Events Overview.................................................................................................................... Page
2
Header/Footer Token
Functions ..................................................................................................................................... Page
3
TGmPreview Properties
explained (excluding inherited
properties)........................................................................... Page
4
TGmPreview Methods
explained (excluding inherited methods)............................................................................... Page
6
TGmPreview Events
explained (excluding inherited events)...................................................................................... Page
8
Ordering TGmPreview (full
version)................................................................................................................................ Page
This
is a VCL component that encapsulates the Printer object and gives an
interactive
Print Preview exposing many useful functions to the
developer.
Whats best of all is that TGmPreview Lite is a free
component and comes with complete source code!!!
TGmPreview.
I
make no claim to correct functioning of the TGmPreview component, so use it at
your own risk.
The
full version with the extra the features, marked with (full) is available
with source code for $15 USD (£10 UK
pounds) from Murt Software.
Make sure you check the website regularly
for updates.
Because
the TGmPreview component inherits from the TScrollingWinControl component, I am
only going to document the new properties, methods and events, which are
specific to this component.
If you need help with the inherited properties then look in the Delphi help file under TScrollingWinControl.
Properties
q
About q
AllowMouseZoom q
CanvasBrush q
CanvasFont q
CanvasPen q
CurrentPage q
CollatePrinting (full) q NumPages q NumCopies q Footer q Alignment (full) q Brush q Font q Text q Line q ShowLine q Visible q Header q Alignment (full) q Brush q Font q Text q Line q ShowLine q Visible q Margins q MarginColor q ShowMargins q PagesPerSheet (full) q ShowPrintProgress (full) q ShadowColor q ShadowWidth q ShowShadow q Zoom |
Methods q
AbortPrinting (full) q
AvailablePageWidth q
AvailablePageHeight q
Clear q
FirstPage q
LastPage q
MarginLeft q
MarginTop q
MarginRight q
MarginBottom q
MarginRect q
MmMoveTo q
MmLineTo q
MmEllipse q
MmRectangle q
MmTable q
MmDraw q
MmStretchDraw (full) q
MmTextOut q
NewPage q
NextPage q
PhysicalPrinterWidth q
PhysicalPrinterHeight q
PrevPage q
Print |
Events q AfterPrint q BeforePrint q OnAbortPrint (full) q OnClear q OnNewPage q OnPageChange q OnPageDraw q OnPrintProgress q OnZoom |
Note
(full) - These
features are only available in the full version, which costs $15.00 USD
/ £10 UK Pounds
See the end of
this document for ordering details and information |
The header and footer also have the ability
to utilize tokens to enable the printing of dynamic fields.
The tokens available are
{PAGE} - replaced with the current
page number
{NUMPAGES} - replaced with the total number of pages
{DATE} - replaced with the date of printing
{TIME} - replaced with the time of
printing
e.g. If your footer text was
Page {PAGE} of
{NUMPAGES}
your printer output would be
Page 1 of 3, Page 2
of 3, Page 3 of 3 (for a 3 page
document)
property, TGmPreview
property
About;
The About property has a button which,
when pressed, opens a small dialog box giving the following details
q Component version
q E-mail contact
q Website address
property, TGmPreview
property
AllowMouseZoom: boolean;
The AllowMouseZoom property determines
weather the left and right mouse buttons are used for zooming in and out of the
preview at runtime.
property, TGmPreview
property
CanvasBrush: TBrush;
Use CanvasBrush to read or set the
current drawing brush.
property, TGmPreview
property
CanvasFont: TFont;
Use CanvasFont to read or set the current
drawing font.
property, TGmPreview
property CanvasPen:
TPen;
Use CanvasPen to read or set the current
drawing pen.
property, TGmPreview
property NumCopies:
integer;
NumCopies specifies the number of copies to print when
the TGmPreview.Print method is called.
property, TGmPreview
property
CollatePrinting: boolean;
CollatePrinting is property which gives the option to collate the pages when
printing.
E.g. below shows the sequence of printing
pages when printing three copies of a three page document
CollatePrinting = True - 1,2,3 1,2,3 1,2,3
CollatePrinting = False - 1,1,1
2,2,2 3,3,3
property, TGmPreview
property
CurrentPage: integer;
CurrentPage returns the current page being displayed by
the print preview. The current page is also the active page on which all
drawing is done. Set CurrentPage to change the page.
property, TGmPreview
property Header:
TGmHeaderFooter;
The component Header is made up of the
following group of sub-properties
q Alignment TAlignment (full) (taLeftJustify, taCentre,
taRightJustify)
q Text string The
text to display in the header
q Font: TFont The
font to use for the header
q Brush TBrush The
brush to use for the header
q Line TPen The
pen to use for drawing the header line
q ShowLine Boolean Determines
weather the line is visible
q Visible: Boolean Determines
weather the header (including the line) is visible.
property, TGmPreview
property Footer:
TGmHeaderFooter;
See Header (above)
property, TGmPreview
property NumPages:
integer;
NumPages returns the total number of pages in the
TGmPrinter component.
property, TGmPreview
property
ShadowColor: TColor;
ShadowColor is the color of the shadow
which is displayed on the right and bottom edges of the page.
property, TGmPreview
property
ShadowWidth: integer;
ShadowWidth is the width/offset of the
shadow. Increasing the ShadowWidth will create a thicker shadow around the
page.
property, TGmPreview
property
ShowPrintProgress;
This property determines whether a small box
appears during printing. On this print dialog box is a progress summary and an
abort print method
property, TGmPreview
property
ShowShadow: boolean;
ShowShadow determines weather the
preview page shadow is visible or not.
property, TGmPreview
property Zoom:
integer;
Zoom specifies the zoom factor
of the preview. Read this property to obtain the current zoom and set this
property to change the preview zoom and update the display.
method, TGmPreview
procedure
AbortPrinting;
Calling this method will cause the printing
to stop at the position it has reached.
method, TGmPreview
property
AvailablePageWidth: integer;
AvailablePageWidth returns the available
printing width of the printer canvas in pixels.
Result
= PhysicalPageWidth (MarginLeft + MarginRight)
method, TGmPreview
property
AvailablePageHeight: integer;
AvailablePageWidth returns the available
printing width of the printer canvas in pixels.
Result
= PhysicalPAgeHeight (MarginTop + MarginBottom)
method, TGmPreview
procedure
Clear;
Calling clear will clear all of the existing
pages, remove all pages from 2 upwards and set the current page to 1.
method, TGmPreview
procedure First;
Calling First will jump to
the first page of the component and update the preview.
method, TGmPreview
procedure
Last;
Calling NextPage will jump to the last page of the component and update the
preview.
method, TGmPreview
property
MarginLeft: integer;
MarginLeft returns the left margin in printer
pixels measured from the left of the page.
method, TGmPreview
property
MarginRect: TRect;
MarginRect returns the
above 4 margin values in a TRect structure.
method, TGmPreview
property
MarginRight: integer;
MarginRight returns the
right margin in printer pixels measured from the right of the page.
method, TGmPreview
property MarginTop:
integer;
MarginTop returns the top
margin in printer pixels measured from the top of the page.
method, TGmPreview
procedure
MmMoveTo(X,Y: double);
MmMoveTo is a wrapper for the standard Canvas.MoveTo
procedure except that the parameters, X and Y take values specified in
millimeters.
method, TGmPreview
procedure
MmEllipse(X,Y,X2,Y2: double);
MmEllipse is a wrapper
for the standard Canvas.Ellipse procedure except that the parameters,
X,Y,X2 and Y2 take values specified in millimeters.
X,Y,X2 and Y2 specify the Left,
Top, Right and Bottom edges of the ellipse respectively.
The ellipse outline is drawn
using the current value of the CanvasPen property and is filled with the
value of the CanvasBrush.
method, TGmPreview
procedure
MmRectangle(X,Y,X2,Y2: double);
MmRectangle is a wrapper
for the standard Canvas.Rectangle procedure except that the parameters,
X,Y,X2 and Y2 take values specified in millimeters.
X,Y,X2 and Y2 specify the Left,
Top, Right and Bottom edges of the rectangle respectively.
The rectangle outline is drawn
using the current value of the CanvasPen property and is filled with the
value of the CanvasBrush.
method, TGmPreview
procedure MmTable(X,Y,X2,Y2:
double; ARows,ACols: integer);
MmTable is a procedure
which draws a table/grid on the page of a given number of rows and columns.
X,Y,X2 and Y2 specify the Left,
Top, Right and Bottom edges of the rectangle respectively these are all
specified in millimeters.
The table is drawn with the
number of rows and columns given by ARows and Acols All columns and rows are
drawn with an equal distribution across the table.
The table outline is drawn using
the current value of the CanvasPen property and is filled with the value
of the CanvasBrush.
method, TGmPreview
procedure
MmDraw(X,Y: double; AGraphic: TGraphic);
MmDraw is a wrapper
for the standard Canvas.Draw procedure except that the parameters, X and
Y take values specified in millimeters. X and Y specify the left and top of the
graphic respectively. AGraphic gives the graphic object to draw on the page.
method, TGmPreview
procedure
MmStretchDraw(ARect: TRect; AGraphic: TGraphic);
MmStretchDraw is a wrapper
for the standard Canvas.MmStretchDraw procedure
except that the Arect parameter takes values specified in millimeters. AGraphic
gives the graphic object to draw on the page stretched to fit in the ARect
coordinates.
method, TGmPreview
procedure MmTextOut(X,Y:
double; AText: string);
MmTextOut is a wrapper
for the standard Canvas.TextOut procedure except that the parameters, X
and Y take values specified in millimeters. The text font is specified by the CanvasFont
property. The font background is given by the value of the Canvas.Brush
property.
method, TGmPreview
procedure
Newpage: Integer;
Calling
new page will create a new page in the TGmPrinter component and automatically
jump to that page (the last page). The number of the page added will be
returned.
method, TGmPreview
procedure NextPage;
Calling NextPage will jump to the next page of the component and update the
preview.
method, TGmPreview
property
PhysicalPrinterHeight: integer;
PhysicalPrinterHeight returns the physical
printing width of the printer canvas in pixels.
method, TGmPreview
property
PhysicalPrinterWidth: integer;
PhysicalPrinterWidth returns the physical
printing width of the printer canvas in pixels.
method, TGmPreview
procedure PrevPage;
Calling PrevPage will jump
to the first page of the component and update the preview.
method, TGmPreview
procedure Print;
Calling Print will print all pages in the TgmPreview component to the
current printing device.
event, TGmPreview
procedure
TGmPrinterAfterPrint(Sender: Tobject);
The
AfterPrint event triggers after the printing has finished.
event, TGmPreview
procedure
TGmPrinterBeforePrint(Sender: Tobject);
The
BeforePrint event triggers before the printing has started.
event, TGmPreview
procedure
TGmPrinterAbortPrint(Sender: Tobject);
The
OnAbortPrint event triggers if the user aborts the printing before it
has finished.
event, TGmPreview
procedure
TGmPrinterClear(Sender: Tobject);
The
OnClear event triggers after the clear method is called.
event, TGmPreview
procedure
TGmPrinterNewPage(Sender: Tobject);
The
NewPage event triggers after the NewPage method is called.
event, TGmPreview
procedure
TGmPrinterPageChange(Sender: Tobject);
The
OnPageChange event triggers after the when the current preview page is
changed by using any of the following methods
event, TGmPreview
procedure
TGmPrinterDrawPage(Sender: Tobject);
The
OnPageDraw event triggers when either the page is drawn on or the Clear
method is called.
event, TGmPreview
procedure
TGmPrinterPageNavigate(Sender: Tobject);
The
OnPageNavigate event triggers after when the value of the Current
Page changes.
event, TGmPreview
procedure
TgmPrinterPrintProgress(Sender: Tobject);
The
OnPrintProgress event triggers after each page of the preview component
has successfully printed.
event, TGmPreview
procedure
TGmPrinterZoom(Sender: Tobject);
The
OnZoom event triggers after the value of the Zoom property
changes.
By ordering TGmPreview, I will provide you with the following
q Full component including full source code
q Free E-mail support
q Free updates to future versions
q E-mail notification of any new releases and bug-fixes
The price of this component is $15 US Dollars or £10
UK Pounds.
The component will be sent to you via E-mail or on a floppy disk whichever suits you best.
If you would like to order this component then send an e-mail to me at
gmurt@freeuk.com and I will give you the address to which to send the cheque or cash.
The component will be distributed to you on receiving the payment.
Regards,
Graham Murt (TGmPreview Author)