|
|
Introduction
The Visual Basic PrintForm function basically
prints a bitmap based screen dump of a Visual Basic form.
qPrinter 1.6 includes the FormPrint method. The FormPrint
method uses the same print/previewing capabilities of the qPrinter
project to create documents based on the text-based controls on a
form featuring word-wrap, borders, font styles and alignment.
The FormPrint method examines Text boxes, List
boxes, Combo boxes, Check boxes, Option buttons and Labels. It
retrieves the font properties of the control and the text or caption
value and creates an absolutely positioned qPrinter TextItem and
places it in the document relative to its position on the form.
Textboxes whose contents are greater than the
control's dimensions can be extended to allow all the contents to
fit.
The FormPrint_Update method can be used to update
the contents of the document, for example if the user edits/enters
information the document can be updated with the changes.
For an example, see the screenshot
page.
| FormPrint Method |
| Parameters |
frmPrint As Object
[Optional ContainParent As Object]
[Optional FormAlign As qePrinterAlign = eLeft]
[Optional InputBorder As Boolean = False]
[Optional TopOffset As Single]
[Optional AutoHeight As Boolean = True]
[Optional ExcludeList As String] |
| Description |
The Method will create a qPrinter
document and fill it with absolutely position TextItems by
retrieving information from the controls in 'frmPrint' and/or
'ContainParent' where 'ContainParent' is a container control
e.g. PictureBox.
The alignment of the controls on the page is determined by the
'FormAlign' parameter. The document items can be
stretched to fit across the page using 'eJustify'.
Borders can be set around items based on TextBox, ComboBox and
ListBox controls.
The 'TopOffset' parameter can be used to position the contents
of the document from the top of the page.
The 'AutoHeight' parameter determines whether TextItems are
expanded to hold the full content of a control or retain the
original dimensions of the associated control.
The 'ExcludeList' parameter can be used to list controls that
should not be included in the document. Each item in the
list should be prefixed by an asterisk '*' like:
"*Label1*Label2*Label3"
Items in a control
array should be listed in the format '*Name/Index'.
To exclude Label1(0) and Label1(1) use:
"*Label1/0*Label1/1" |
| Notes |
| Access
TextItems |
Each
control has an associated TextItem in the document. The
TextItem's key is in the format: ControlName or
ControlName/Index for controls in a control
array. Example:
qPrint.TextItem("Text1")
qPrint.TextItem("Text1/0")
You can change any of the TextItem
properties after the FormPrint call.
|
| Text
format |
The
FormPrint method does not recreate the word-wrap of a TextBox.
The calculations for word-wrap in the document are based on
the measurements for printing the text to the Printer object -
these measurements can vary between control and printer, even
when both have the same Fontsize. |
| Option
Buttons |
The
FormPrint method only prints the selected Option caption.
It calculates the position by determining firstly whether an
Option in a group is closest to the top-left of the form.
The selected Option caption is placed in this position in the
document. If the widths of the Options in the group are
different it allows for the widest. |
| Recalling
the Method |
Each time
the FormPrint method is called it destroys the TextItem
collection before creating a new document based on the form
passed to it. Changes or additional TextItems added to
the qcPrinter class will also be destroyed. |
| |
| FormPrint_Update Method |
| Parameters |
frmPrint As Object |
| Description |
The Method extracts the
text/caption value from controls held in the document and
updates the text in those TextItems.
If the AutoHeight parameter of the FormPrint method was set
to True then the project will check and readjust sizes where
required.
|
| Notes |
| Error Messages |
There are two possible errors.
Firstly that FormPrint method hasn't been called before
FormPrint_Update so there is nothing to update.
Secondly, the form passed to the method is different to the
form passed in the FormPrint method. |
| |
|