Documents
NextGrid & NextDBGrid
- Html Column Tutorial
- Upgrade existing projects for loading changes
- Edit events in NextGrid
- NextGrid Vista Style
- NextGrid How To
- Integrating Inplace Editors
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- Using Editors in runtime
- FieldChooser Tutorial
- Grid Report Tutorial
NextGrid
- TreeColumn Tutorial
- NextGrid Quick Start
- Custom Draw in NextGrid
- Export to XML from NextGrid
- Optimize NextGrid
- NextGrid Custom Sorting
- VirtualColumn Tutorial
- Graphic Column Tutorial
NextDBGrid
- NextDBGrid Quick Start
- NextDBGrid Events
- NextDBGrid How To
- Sorting records in NextDBGrid
- LookupColumn Tutorial
NextInspector
- ToolbarItem tutorial
- NextInspector Advanced tutorial
- NextDBInspector Tutorial
- NextInspector Item Types
- Map VCL property to item
- NextInspector Quick Start
NextSheet
NextCollection
- NxAlertWindow Tutorial
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxPathControl Quick Start
- NxFlipPanel and NxHeaderPanel Quick Start
- NxOutlookBar Tutorial
- NxPageControl and NxNotebook Quick Start
- NxButton Tutorial
Misc
- Component Names Change
- NxComboBox styles
- Numeric FormatMask
- NxVirtualDataSet tutorial
- DateTime FormatMask
- NxPreview Quick Start
- Quick update
- 32bit Bitmaps Tutorial
- Enable typing unicode characters in InplaceEditors
- Using NxColorScheme
- NxProgress Tutorial
- NxAutoCompletion Tutorial
Labs
NextGrid .NET
NxPreview Quick Start
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Wim van der Vegt
- Created:
- Updated: 2008-04-26
Downloads
It provides a multipage canvas at full printer resolution that an application can draw upon. NxPreview supports drawing and printing in color if the printer does too.

With a single OnRender event both the preview and the printing are done at the printers full resulution, thus eliminating any scaling problems.
In this OnRender event the following common sequence is used to print:
Example:
BeginPage; //Draw NewPage; //Draw EndDoc;
Drawing is performed on a MetaCanvas that has the same dimensions as the selected printer. The following code from the demo draws the separate areas onto a page:
with TNxPreview(Sender) do begin BeginDoc; with MetaCanvas do begin //Draw first page Rectangle(Body); MoveTo(Body.Left, Body.Top); LineTo(Body.Right, Body.Bottom); MoveTo(Body.Left, Body.Bottom); LineTo(Body.Right, Body.Top); if pdHeader in PrintItems then TextOut(Header.Left + LeftMargin, Header.Top, 'Header'); TextOut(Body.Left + 40 * CharWidth, Body.Top + CharHeight, 'Body'); if pdFooter in PrintItems then TextOut(Footer.Left + LeftMargin, Footer.Bottom - CharHeight, 'Footer'); if pdLeftMargin in PrintItems then for i := 1 to Length('Left Margin') do TextOut(Body.Left - LeftMargin + CharWidth, Body.Top + i * CharHeight, 'Left Margin'[i]); end; EndDoc; end;
Beware when using code like above demo code that it's not allowed to use BeginDoc, NewPage or EndDoc inside a "with MetaCanvas do" block. These statements change the current MetaCanvas drawn upon (and referenced by the "with/do" statement) something Delphi doesn't like.
The output looks like the screenshot below.

In this screenshot the hatched area is the non-printable area as reported by the printer driver. Normally the application only draws within the Body rectangle. If present, the Header/Footer and Left Margin are automatically generated by the NxPreview component. If one or more of these areas are ommitted from the PrintItems property the Body is automatically adjusted so it includes the ommitted area too.
The NxPreview Dialog is shown by the following code:
NxPreview.Execute(poPreview);
The possible parameters for the Execute function are:
Name | Meaning |
---|---|
poPreview | Shows the preview dialog after calling the OnRender Event |
poPrintSetup | Shows the Print Setup Dialog |
poReportSetup | Fires the OnReportSetup event that the application can use to let the user alter whats printed. |
poPrint | Directly prints after firing the OnRender event. |
Inside the NxPreview dialog, the OnReportSetup event is fired when the Report setup button is pressed. The button is disabled when no event is attached.
The OnJob event provides access to the Printing Jobs in the Spooler. It is called once for every Job when the Jobs property is retrieved.
With the runtime Settings property one can specify the name of an ini file where to store or load the most important printing settings. By default it points to a file based on the Applications name with an .ini extension.
For the headers and footers a number of opcodes are available that are replaced at runtime. Within the aplication the Parameter property can be used to define additional opcodes by using the "name=value" syntax of the TStringList class. Opcodes in the HeaderText and FooterText property must be enclosed in quare brackets.
Name | Meaning |
---|---|
[Page] | The actual page number |
[Date] | Expanded to the output of DateToStr(Now) |
[DateTime] | Expanded to the output of DateTimeToStr(Now) |
[Ldate] | Expanded to the output of FormatDateTime('dddddd') |
[Time] | Expanded to the ouput of TimeToStr(Now) |