Type | Description | |||
Boolean | A Boolean expression that specifies whether the Print object is released automatically when it is not required anymore. |
The AutoRelease property on False, is useful, if you create the Print object locally at runtime. If created locally, the Print object is released when it is out of scope, or when the procedure ends.
For instance, in the following VB6 sample the user creates a Print object as a local variable, and so the object is released as soon as the Form_Load ends. In other words, you will notice that the Preview window is opened and closed quickly, as it is closed because the Exontrol.Print object is released as soon as the Form_Load function ends.
Private Sub Form_Load() With CreateObject("Exontrol.Print") .PrintExt = G2antt1.Object .Preview End With End Sub
This problem can be solved in 2 ways:
as shown in the following samples:
Let's use the AutoRelease property, so the code is like follows. This time, if running the sample, the Preview window will be shown, and the Exontrol.Print object is released as soon as the user closes the Preview's mainframe.
Private Sub Form_Load() With CreateObject("Exontrol.Print") .AutoRelease = False .PrintExt = G2antt1.Object .Preview End With End Sub
And another solution is declaring a public member of Exontrol.Print type, so it will be available, as form lives as described bellow. This time, if running the sample, the Preview window will be shown, not closed, as the object p is released ONLY when closing the form.
Dim p As Object Private Sub Form_Load() Set p = CreateObject("Exontrol.Print") With p .PrintExt = G2antt1.Object .Preview End With End Sub