PrintCancel

Cancels printing and deletes the spool file, if any. There are two syntaxes.

To

Use

Cancel printing of a DataWindow or DataStore printed with the Print function.

Syntax 1 For DataWindows and DataStores

Cancel a print job that you began with the PrintOpen function. For the PowerBuilder environment only.

For a description of PowerBuilder system print commands, see the PowerScript Reference.

Syntax 2 For canceling a print job


Syntax 1 For DataWindows and DataStores

Description

Cancels the printing of a DataWindow or DataStore that was printed using Syntax 1 of Print.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object

Web ActiveX

DataWindow control, DataWindowChild object

Syntax

PowerBuilder

integer dwcontrol.PrintCancel ( )

Web ActiveX

number dwcontrol.PrintCancel ( )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore object, or child DataWindow.

Returns

Returns 1 if it succeeds and –1 if an error occurs. If dwcontrol is null, PrintCancel returns null.

Usage

PrintCancel cancels the printing of the specified DataWindow or DataStore by deleting the spool file, if any, and closing the job.

NotePowerBuilder environment When you use the Print method to print the DataWindow or DataStore, without using PrintOpen, use Syntax 1 to cancel printing. When you use the PowerScript system function PrintDataWindow to print a DataWindow as part of a print job, use Syntax 2 to cancel printing.

When you use Print for DataWindow controls or DataStores, it triggers a PrintStart event just before any data is sent to the printer (or spooler), a PrintPage event for each page break, and a PrintEnd event when printing is complete. You can use PrintCancel in the PrintStart or PrintPage event to cancel printing.

Examples

Example 1

This statement sends the contents of the DataWindow dw_employee to the current printer without displaying the Cancel dialog:

dw_Employee.Print(FALSE)

This statement in the PrintStart event cancels printing:

dw_employee.PrintCancel()

See also


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

integer PrintCancel ( long printjobnumber ) 

Argument

Description

printjobnumber

The number the PrintOpen function assigned to the print job.

Returns

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

Example 2

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:

boolean gb_printcancel

Example 3

The script for the Print button is:

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:\PB\bitmap1.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)

Example 4

The script for the cancel button in the second window is:

gb_printcancel = true

Close(w_printcancel)

See also