Sets the application-defined abort function that allows a print job to be canceled during spooling.
Sub Printer_AbortProc(hDC%, error%, Cancel?)
Before you start a print job, you can establish an abort procedure simply by including Printer_AbortProc sub event into your GFA-BASIC 32 application. All the necessary initialization is performed automatically by GFA-BASIC 32..
GDI calls the AbortProc every 2 seconds during a print job to inform the application of spooler errors and to allow the application to abort the job when desired. GDI calls the AbortProc function with information about why it is being called; this value is either an error code from the spooler or zero, which indicates that the function is being called simply to allow an abort.
hDC% Handle to the device context for the print job.
error% Specifies whether an error has occurred. This parameter is zero if no error has occurred; it is SP_OUTOFDISK if Print Manager is currently out of disk space and more disk space will become available if the application waits.
Cancel?Return TRUE to cancel the print job, or False to continue.
Lprint
Printer.EndPage ' Error condition
Printer.EndDoc
Do
Sleep
Loop
Sub Printer_AbortProc(hDC%, iError%, Cancel?)
Debug hDC%; iError%
Cancel = 1
EndSub
Most applications give the user an opportunity to abort a print job by providing a dialog box with a cancel button or a variation on that theme. An application can use several time slices during a print job to check for a user cancellation of the printing. When GDI calls the AbortProc function, the printing process is yielding to the application for exactly such purposes; this is a good opportunity to check for user input. When the application itself is performing a time-intensive operation, it can yield to the abort-checking code when desired.
When using a Cancel dialog box add DoEvents to the Printer_AbortProc so that the application can process the mouse message.
{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}