Syntax 2 For canceling a print job
Description
Cancels printing of a print job that you opened with the PrintOpen
function. The print job is identified by the number returned by
PrintOpen.
Applies to
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataWindow control |
Syntax
PowerBuilder
|
1 |
integer PrintCancel ( long printjobnumber ) |
|
Argument |
Description |
|---|---|
|
printjobnumber |
The number the PrintOpen function assigned to the |
Return value
Returns 1 if it succeeds and -1 if an error occurs. If
printjobnumber is null, PrintCancel returns null.
Usage
PrintCancel cancels the specified print job by deleting the spool
file, if any, and closing the job. Because PrintCancel closes the print
job, do not call the PrintClose function after you call
PrintCancel.
Examples
In this example, a script for a Print button opens a print job and
then opens a window with a cancel button. If the user clicks on the
cancel button, its script sets a global variable that indicates that the
user wants to cancel the job. After each printing command in the Print
button’s script, the code checks the global variable and cancels the job
if its value is true.
The definition of the global variable is:
|
1 |
boolean gb_printcancel |
The script for the Print button is:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
long job, li gb_printcancel = false job = PrintOpen("Test Page Breaks") IF job < 1 THEN MessageBox("Error", "Can't open a print job.") RETURN END IF Open(w_printcancel) PrintBitmap(Job, "d:PBitmap1.bmp", 5, 10, 0, 0) IF gb_printcancel = true THEN PrintCancel(job) RETURN END IF ... // Additional printing commands, ... // including checking gb_printcancel PrintClose(job) Close(w_printcancel) |
The script for the cancel button in the second window is:
|
1 2 |
gb_printcancel = true Close(w_printcancel) |
See also
PrintCancel in the section called “PrintCancel” in PowerScript Reference
PrintClose in the section called “PrintClose” in PowerScript Reference
PrintOpen in the section called “PrintOpen” in PowerScript Reference