Documents
NextGrid & NextDBGrid
- Integrating Inplace Editors
- Upgrade existing projects for loading changes
- Grid Report Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- NextGrid How To
- Html Column Tutorial
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- Edit events in NextGrid
- NextGrid Vista Style
NextGrid
- NextGrid Quick Start
- Graphic Column Tutorial
- Optimize NextGrid
- Custom Draw in NextGrid
- VirtualColumn Tutorial
- Export to XML from NextGrid
- NextGrid Custom Sorting
- TreeColumn Tutorial
NextDBGrid
- Sorting records in NextDBGrid
- NextDBGrid Events
- NextDBGrid Quick Start
- NextDBGrid How To
- LookupColumn Tutorial
NextInspector
- NextInspector Item Types
- NextInspector Quick Start
- NextDBInspector Tutorial
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- Map VCL property to item
NextSheet
NextCollection
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxAlertWindow Tutorial
- NxPathControl Quick Start
- NxButton Tutorial
- NxOutlookBar Tutorial
- NxFlipPanel and NxHeaderPanel Quick Start
- NxPageControl and NxNotebook Quick Start
Misc
- DateTime FormatMask
- NxAutoCompletion Tutorial
- Using NxColorScheme
- NxComboBox styles
- Enable typing unicode characters in InplaceEditors
- NxProgress Tutorial
- NxPreview Quick Start
- Numeric FormatMask
- NxVirtualDataSet tutorial
- Component Names Change
- 32bit Bitmaps Tutorial
- Quick update
Labs
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) |
Comments
2009-02-14 05:55:13
NlgglW kjyvobbsviot, owyuxuratmzq, [link=http://lctehcvetohq.com/]lctehcvetohq[/link], http://kzcmzcwhlbpq.com/