The Exontrol ExPrint component is an advanced printing system specifically to bring your User Interface to the printed page. The ExPrint adds powerful print and preview capabilities to your forms, dialog boxes or other windows.
The control's release notes can be found on our web site, looking for the
Release Notes/What's new column in the control's main page. Click here
for direct link.
Generally, the PrintExt/PrintExts (starting from 6.1) property of the eXPrint component
needs to refer the object to be printed as in the following samples:
If you are using the /COM version you can ALWAYS invokes the
control's Print and Print Preview using the following code, no matter of
your programming language, of your development environment such as
Unipaas, SmallTalk, and so on
In other words, just call the Template property of the control with
specified string ( red string ) , as you would change the control's
Background color.
Next samples define the callPreview subroutine which invokes the Print
and Print-Preview of eXG2antt
component.
Access. The Object method of the G2antt1 object gets the
native or the original component.
Private Sub callPreview()
With Print1
Set .PrintExt = G2antt1.Object
.preview
End With
End Sub
VB6. The Object method of the G2antt1 object gets the
native or the original component.
Private Sub callPreview()
With Print1
Set .PrintExt = G2antt1.Object
.Preview
End With
End Sub
VFP. The Object method of the G2antt1 object gets the
native or the original component.
with thisform.Print1
.PrintExt = thisform.G2antt1.Object
.Preview
endwith
VB.NET ( /COM ). The GetOcx
method of the G2antt1 object gets the native or the original
component.
Private Sub callPreview()
With AxPrint1
.PrintExt = AxG2antt1.GetOcx()
.Preview()
End With
End Sub
VB.NET ( /NET ).
Private Sub callPreview()
With Exprint1
.PrintExt = Exg2antt1
.Preview()
End With
End Sub
VB.NET ( /WPF ). Declares
and initializes a member exprint of
exontrol.EXPRINTLib.exprint type, as in the following code
Private exprint As exontrol.EXPRINTLib.exprint = New exontrol.EXPRINTLib.exprint()
Private Sub callPreview()
With exprint
.PrintExt = Exg2antt1
.Preview()
End With
End Sub
C# ( /COM ). The GetOcx
method of the G2antt1 object gets the native or the original
component.
C++ (6.0). The m_print member of the CWindowMFCDlg class,
is of CExPrint type ( which has been defined by the class wizard
). The m_g2antt member is of CG2antt type that has been defined by
the class wizard. The GetControlUnknown method retrieves a pointer
to IUnknown interface being implemented by the original component,
which is the pointer required by the PrintExt method before
calling the Preview or DoPrint method of the eXPrint component.
C++ (2005,2008). The m_print member of the CWindowMFCDlg
class, is of CExPrint type ( which has been defined by the class
wizard ). The m_g2antt member is of CG2antt type that has been
defined by the class wizard. The GetControlUnknown method
retrieves a pointer to IUnknown interface being implemented by the
original component, which is the pointer required by the PrintExt
method before calling the Preview or DoPrint method of the eXPrint
component.
C++ Builder (2009). The DefaultDispatch function of the
TOleControl retrieves the original object, so it can be passed to
PrintExt function of the eXPrint in order to print or print
preview the component, as seen in the callpreview function:
X++ (Dynamics Ax 2009). The PrintExt function of the
eXPrint component must point to the object to be printed. The
following sample shows the print-preview for the exg2antt1
component.
Delphi (2009). The DefaultDispatch function of the
TOleControl retrieves the original object, so it can be passed to
PrintExt function of the eXPrint in order to print or print
preview the component, as seen in the callpreview function:
procedure callPreview(P : TPrint; G : TG2antt);
begin
with P do
begin
PrintExt := G.DefaultDispatch;
Preview();
end;
end;
callPreview( Print1, G2antt1 );
Clarion. Code under ?PrintThis button, with some
properties:
?Print{'Settings(10)'} = 1
?Print{'PrintExt'} = ?Gantt{PROP:Object} ! If we going to print ExG2antt
?Print{'AsScreen'} = False ! Sometimes makes problems under Terminal services
?Print{'PageOrientation'} = 2
?Print{'Caption'} = 'Some text'
?Print{'Settings(6)'} = 1500
?Print{'Settings(7)'} = 1500
?Print{'Settings(8)'} = 1500
?Print{'Settings(9)'} = 1500
?Print{'Font.Name'} = 'Arial'
?Print{'Font.Size'} = 9
?Print{'Preview'}
PowerBuilder (Classic). The Object property of the
control (OLECustomControl) returns the OLE object to be passed to
PrintExt property of the eXPrint like in the following code:
Defines the callPreview new function with one argument g of
OLECustomControl type. The print object indicates the name of the
eXPrint in the Window. The following code, can be used when the
ExPrint is added in design mode, to the Layout page:
The following callPreview function uses the eXPrint being created
at runtime. Declare the OLEObject oPrint in the Instance Variables
page, so the oPrint is known at the time the callPreview is called,
so the callPreview looks as follows:
The callPreview(ole_1) should be called to invoke the
print-preview of ole_1 object. In this case the ole_1 is the
ExG2antt component hosted in the Window.
dBASE Plus. The nativeObject property of the control
(ActiveX) returns the OLE object to be passed to PrintExt property
of the eXPrint like in the following code:
Defines the preview new method with one argument g. The OEXPRINT
object indicates the name of the eXPrint in the form. The following
code, can be used when the ExPrint is added in design mode, to the
form:
function callPreview(o)
local oPrint
oPrint = form.OEXPRINT.nativeObject
oPrint.PrintExt = o
oPrint.Preview()
return
while, the following call can be used to print and print-preview
the control :
CLASS::callPreview(form.Activex1.nativeObject)
where the ActiveX1 is the name of the control to be printed, in
this case is the ExG2antt Chart ActiveX Control.
The following preview function uses the eXPrint being created at
runtime. Declare the public oPrint in as a global variable, so the
oPrint is known at the time the preview is called, so the method
shows as follows:
function callPreview(o)
oPrint = new OleAutoClient("Exontrol.Print")
oPrint.PrintExt = o
oPrint.Preview()
return
while, the following call can be used to print and print-preview
the control :
CLASS::callPreview(form.Activex1.nativeObject)
where the ActiveX1 is the name of the control to be printed, in
this case is the ExG2antt Chart ActiveX Control.
Visual DataFlex. The simplest way to call the Print and
Print/Preview for the component, is using the Template property of
the control as in the following sample
Defines the preview procedure as follows:
Procedure preview Handle g
Set ComTemplate of g to "dim p;p=CreateObject(`Exontrol.Print`);p.AutoRelease=False;p.PrintExt=Me;p.Preview()"
End_Procedure
while, the following call can be used to print and print-preview
the control :
Send preview Self
where the Self indicates the handle of the control to be printed,
in this case is the ExG2antt Chart ActiveX Control ( oComG2antt ).
This method does not require importing the "ExPrint 1.0 Control
Library ( version 1.0 )" to your workspace.
The following method requires, importing the "ExPrint 1.0
Control Library ( version 1.0 )" to your workspace. Check how
you imported the "ExG2antt 1.0
Control Library (version 1.0)" and do the same.
Procedure preview Variant g
Handle hoPrint
Get Create (RefClass(cComPrint)) to hoPrint
Set ComAutoRelease of hoPrint to True
Set ComPrintExts of hoPrint to g
Send ComPreview of hoPrint
//Send Destroy to hoPrint // Prevents closing the Print object, so the Preview will not be shown. AutoRelease will release the object once the Close button is pressed
End_Procedure
while, the following call can be used to print and print-preview
the control :
Send preview (pvComObject(Self))
where the Self indicates the handle of the control to be printed,
in this case is the ExG2antt Chart ActiveX Control ( oComG2antt ).
Xbase++ The simplest way to call the Print and
Print/Preview for the component, is using the Template property of
the control as in the following sample
while, the following call can be used to print and print-preview
the control :
_preview( oControl )
where the oControl indicates the control to be printed, in this
case is the ExG2antt Chart ActiveX Control ( oControl ). This method
does not require creating the "ExPrint 1.0 Control Library (
version 1.0 )" to your project.
The following method requires, creating and using the Preview
method of the the "ExPrint 1.0 Control Library ( version 1.0
)" object.
while, the following call can be used to print and print-preview
the control :
_preview( oPrint, oControl )
where the oControl indicates the the control to be printed, in
this case is the ExG2antt Chart ActiveX Control ( oControl ), and
the oPrint is the "ExPrint 1.0 Control Library ( version 1.0
)" object created using the following code:
The eXPrint control provides the ItemCaption
property which changes the captions to be shown on the toolbar of the
Print/Print Preview. The ItemToolTip
property specifies the tooltip assigned to buttons on the print and
print's preview toolbar.
With Print1
.ItemCaption(exToolBarSetup) = "<img>4</img>Einrichtungsdatei..."
.ItemToolTip(exToolBarSetup) = .ItemCaption(exToolBarSetup)
.ItemCaption(exToolBarClose) = "<img>6</img>Schließen"
.ItemToolTip(exToolBarClose) = .ItemCaption(exToolBarClose)
.ItemCaption(exToolBarPrint) = "<img>5</img>Ausdrucken"
.ItemToolTip(exToolBarPrint) = .ItemCaption(exToolBarPrint)
Set .PrintExt = G2antt1.Object
.Preview
End With
The ItemCaption property should be called before Preview/DoPrint method.
The eXPrint control provides the PageOrientation
or Settings(exPageOrientation)
property specifies the page's orientation. The following sample changes
the page's orientation to landscape:
With Print1
.PageOrientation = exLandscape
Set .PrintExt = G2antt1.Object
.Preview
End With
or:
With Print1
.Settings(exPageOrientation) = 2
Set .PrintExt = G2antt1.Object
.Preview
End With
The PageOrientation or Settings(exPageOrientation) property should be called before
Preview/DoPrint method.
change the style of grid line to a solid line, during printing
The following VB sample changes the AsScreen property:
With Print1
.AsScreen = True
Set .PrintExt = G2antt1.Object
.Preview
End With
The following VB sample changes the style of grid lines property,
using the Refreshing/Refresh events:
Dim nGridLineStyle As Long
Private Sub Print1_Refreshing()
nGridLineStyle = G2antt1.GridLineStyle
G2antt1.GridLineStyle = exGridLinesSolid
End Sub
Private Sub Print1_Refresh()
G2antt1.GridLineStyle = nGridLineStyle
End Sub
With Print1
Set .PrintExt = G2antt1.Object
.Preview
End With
The following VB sample changes the style of grid lines property:
With Print1
Dim nGridLineStyle As Long
nGridLineStyle = G2antt1.GridLineStyle
G2antt1.GridLineStyle = exGridLinesSolid
Set .PrintExt = G2antt1.Object
.Preview
G2antt1.GridLineStyle = nGridLineStyle
End With
The eXPrint control communicates with the object to be printed, and
generally the way the control shows on the screen, the same data is sent
to the eXPrint component. So, if you need to provide a different view in
the Print and Print-Preview, you need to handle the Refreshing
and Refresh
events. The Refreshing event is sent just before the eXPrint is doing
the previewing, while the Refresh event is called once all control is
previewed. In conclusion, the idea is to change the control on the back
to look as you want to get in the preview, and restore the state when
Refresh event occurs.
In the following sample, we print no columns for the eXG2antt
control:
Private Sub Print1_Refreshing()
With G2antt1
.BeginUpdate
For Each c In .Columns
c.Visible = False
Next
End With
End Sub
Private Sub Print1_Refresh()
With G2antt1
For Each c In .Columns
c.Visible = True
Next
.EndUpdate
End With
End Sub
The sample hides all the columns during the Refreshing event, and
locks the update of the control during previewing, and restore all
columns ( visibility ) when Refresh event is called.
Basically, Refreshing/Refresh is the idea of how you can personalize
the view of your Print and Print-Preview for any of our controls.
The eXPrint control provides HTMLPicture to load pictures from your
file, resources or BASE64 encoded-strings. Having this, you can use the
<img> HTML tag to Caption or ExtraCaption property to include your
logo to header/footer of each printed page.
The following sample shows how you can display your logo in the Print
and Print-Preview:
With CreateObject("Exontrol.Print")
.PageOrientation = 2
.HTMLPicture("logo") = "E:\exontrol.logo.png"
.ExtraCaption "logo","<img>logo</img>",1,1
.PrintExt = Control.Object
.Preview
End With
The quality of the Print and Print-preview suffer when using any of the following properties:
AsScreen property on True ( Semi-Transparent objects )
Options property includes the FitToPage field ( Fit-To-Page feature )
The Print and Print-Preview show the best on 100%, but the
quality of the Print-Preview is losing once you magnify the page, no matter of
the Settings(exPrintQuality) property.
What can I do? You can check if the component provides the CopyTo
method, and use it to save the control's data to an EMF file, which can be
opened with and editor such of Microsoft Paint, or any other that can handle EMF
files. The EMF is used as a graphics language for printer drivers. Microsoft recommends that "Windows-format" (WMF) functions only "rarely" be used and "enhanced-format" (EMF) functions be used instead.
The EMF file may not be created in case it is too large ( the control's data is
too large ). The CopyTo method is available for components like eXGrid,
eXG2antt, and so on. The eXPrint's CopyTo
method copies the generated pages to different file types such as: EMF, BMP, JPG,
PDF and so on.