The ExPrint component is an advanced printing system designed to bring your user interface onto the printed page. It provides powerful print and print preview capabilities that can be integrated into forms, dialog boxes, and other windows, enabling consistent and high-quality output of application content.
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.
The ExPrint control supports isolated COM, also known as registration-free activation of COM components. This means that the control can be used without requiring traditional COM registration in the Windows registry. Instead, the control's assembly manifest can be included in your application's manifest file, allowing it to be activated and used without administrative privileges or registry modifications.
The control's assembly manifest is:
Generally, the PrintExt / PrintExts (available starting with version 6.1) property of the ExPrint component must reference the object to be printed.
If you are using the /COM version, you can ALWAYS invoke the control's Print and Print Preview capabilities by using the Template property of the control being printed, regardless of the programming language or development environment, including UniPaaS, Smalltalk, and other COM-compatible environments.
The following VB sample shows how to print and print-preview the ExG2antt component using the Template property of the control:
In other words, simply call the control's Template property with the specified string (shown in red), just as you would when changing 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.
The following VBA code shows how to call the Print and Print-Preview of ExG2antt component in MS Access:
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.
The following VB code shows how to call the Print and Print-Preview of ExG2antt component in VB6:
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.
The following VFP code shows how to call the Print and Print-Preview of ExG2antt component in Visual FoxPro:
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.
The following VB.NET code shows how to call the Print and Print-Preview of ExG2antt component (/COM version into /NET forms):
Private Sub callPreview()
With AxPrint1
.PrintExt = AxG2antt1.GetOcx()
.Preview()
End With
End Sub
VB.NET (/NET).
The following VB.NET code shows how to call the Print and Print-Preview of ExG2antt component (/NET version into /NET forms):
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
The following VB.NET code shows how to call the Print and Print-Preview of ExG2antt component (/WPF version):
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.
The following C# code shows how to call the Print and Print-Preview of ExG2antt component (/COM version into /NET forms):
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.
The following C++ code shows how to call the Print and Print-Preview of ExG2antt component in Visual C++ 6.0:
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.
The following C++ code shows how to call the Print and Print-Preview of ExG2antt component in Visual C++ 2005 or 2008:
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
The following C++ code shows how to call the Print and Print-Preview of ExG2antt component in C++ Builder 2009:
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.
The following X++ code shows how to call the Print and Print-Preview of ExG2antt component in Dynamics Ax 2009:
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
The following Delphi code shows how to call the Print and Print-Preview of ExG2antt component in Delphi 2009:
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.
The following Clarion code shows how to call the Print and Print-Preview of ExG2antt component in Clarion:
?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 object.
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.
The following PowerBuilder code shows how to call the Print and Print-Preview of ExG2antt component in PowerBuilder (Classic):
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
The following PowerBuilder samples shows how to call the Print and Print-Preview of ExG2antt component in PowerBuilder (Classic):
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
The following dBASE Plus code defines the callPreview function to call the Print and Print-Preview of ExG2antt component in dBASE Plus:
function callPreview(o)
local oPrint
oPrint = form.OEXPRINT.nativeObject
oPrint.PrintExt = o
oPrint.Preview()
return
The following dBASE Plus code shows how to call the Print and Print-Preview of ExG2antt component in dBASE Plus:
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
The following dBASE Plus code defines the callPreview function to call the Print and Print-Preview of ExG2antt component in dBASE Plus:
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:
The following dBASE Plus code shows how to call the Print and Print-Preview of ExG2antt component in dBASE Plus:
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 invoke the component's Print and Print Preview capabilities is by using the Template property of the control.
The following Visual DataFlex code shows how to call the Print and Print-Preview of ExG2antt component in Visual DataFlex:
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
The following Visual DataFlex sample calls the preview procedure 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.
The following Visual DataFlex samples defines the preview procedure to print and print-preview the control:
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
The following Visual DataFlex sample calls the preview procedure 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 invoke the component's Print and Print Preview capabilities is by using the Template property of the control.
The following Xbase++ code defines the _preview procedure to print and print-preview the control:
The following Xbase++ sample calls the _preview procedure 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.
The following Xbase++ code defines the _preview procedure to print and print-preview the control:
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 is affected by the printer driver, and the settings of the printer driver.
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.
Please make sure that the printer driver is installed and set as default printer on
the new PC. The ExPrint control uses the default printer's settings to
generate the print and print-preview pages. If no printer driver is
installed, the control may take longer time to load, or may not load at
all.