Stopping a print job
There are two ways to stop a print job. The normal way is
to close the job by calling the PrintClose function at the end of
the print job. The other way is to cancel the job by calling PrintCancel.
Using PrintClose
PrintClose sends the current page to the printer or spooler,
closes the print job, and activates the window from which the printing
started. After you execute a PrintClose function call, any function
calls that refer to the job number will fail.
Using PrintCancel
PrintCancel ends the print job and deletes any output that
has not been printed. The PrintCancel function provides a way for
the user to cancel printing before the process is complete. A common
way to use PrintCancel is to define a global variable and then check
the variable periodically while processing the print job.
Assume StopPrint is a boolean global variable. The following
statements check the StopPrint global variable and cancel the job
when the value of StopPrint is TRUE:
1 |
IntJobNbr |
1 |
JobNbr = PrintOpen() |
1 |
//Set the initial value of the global variable. |
1 |
StopPrint = FALSE |
1 |
//Perform some print processing. |
1 |
Do While <i>...</i> |
1 |
. |
1 |
. |
1 |
. |
1 |
// Test the global variable. |
1 |
// Cancel the print job if the variable is TRUE. |
1 |
// Stop executing the script. |
1 |
If StopPrint then |
1 |
PrintCancel(JobNbr) |
1 |
Return |
1 |
End If |
1 |
Loop |