PrintForm prints a Form object using the current printer. The PrintFormWidth and PrintFormHeight properties return the size of the image.
Form.PrintForm[(f%)]
w! = Form.PrintFormWidth[(f%)]
h! = Form.PrintFormHeight[(f%)]
f%:iexp, 0 or 1
w!, h!:Single exp
PrintForm prints all visible objects and bitmaps of the Form object. PrintForm also prints graphics added to a Form object at run time if the AutoRedraw property is True when the graphics are drawn.
The printer used by PrintForm is determined by the Printer object. The image is printed without taking the borders into account. A StartDoc is automatically executed when currently no print job is opened. The image is printed at Printer.CurrentX = 0 and Printer.CurrentY. The size of the image is proportional (formwidth/screenwidth = printwidth/printerwidth). The printwidth is calculated from the Printer.Width and Printer.Height properties. However, when the optional flag f% = 1, the width is calculated using Printer.PageWidth and Printer.PageHeight.
Multiple forms can be printed next to each other by setting Printer.Left.
Once the Printer is initialized, the PrintFormWidth and PrintFormHeight properties can be used to obtain the size of the image. The printer gets initialized after a StartDoc command, or a Lprint command (invokes StartDoc and StartPage implicitly).
OpenW 1
AutoRedraw = 1
Local h As Handle, n As Int32
For n = 1 To 601 Step 100 : Line 0, n, 601, n : Line n, 0, n, 601 : Next n
' A StartDoc is only necessary for
' PrintFormWidth and PrintFormHeight.
Dlg Print Win_1, 0, h
If h <> 0
SetPrinterHDC h
Printer.StartDoc "Text"
Trace Win_1.PrintFormHeight
Trace Win_1.PrintFormWidth
Trace Win_1.PrintFormHeight(1)
Trace Win_1.PrintFormWidth(1)
Me.PrintForm 1
Printer.EndDoc
Debug.Show
EndIf
CloseW 1
The PrintForm method creates a Picture object from the Form. This Picture object is also obtainable using the PrintPicture or PrintPicture2 properties.
{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}