ID Number: Q67203
3.00
WINDOWS
Summary:
SYMPTOMS
Version 3.3 of the PostScript printer driver generates a fatal exit
or an unrecoverable application error (UAE) when Escape(STARTDOC)
is called.
CAUSE
The application has not called Escape(SETABORTPROC) before calling
Escape(STARTDOC).
RESOLUTION
An application that will print to a PostScript printer must export
an abort function and must call Escape(SETABORTPROC).
More Information:
Windows's graphics device interface (GDI) calls the abort function to
cancel the print job or to process out-of-disk-space conditions. An
added benefit of using an abort function is that other applications
are allowed to run while a long print job is processed.
To specify an abort function, an application must first retrieve a
procedure-instance address for the function by using the
MakeProcInstance() call:
lpfnAbortProc = MakeProcInstance(AbortProc, hInst);
Then, call Escape(SETABORTPROC):
Escape(hDC, SETABORTPROC, 0, (LPSTR)lpfnAbortProc, 0L);
The application can then begin printing by using the STARTDOC Escape.
The following is sample code for a typical abort procedure:
BOOL FAR PASCAL AbortProc(HDC hPrnDC, short nCode)
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return TRUE;
}
The following are three important points to remember when using an
abort procedure:
1. If the print job is canceled, or if there is an error, the
application must not attempt to terminate the operation by using
either the Escape(ENDDOC) or Escape(ABORTDOC) call. GDI automatically
terminates the operation before returning the error through either
the NEWFRAME or NEXTBAND Escape call.
2. The abort procedure must be declared in the EXPORTS section of the
module definition (.DEF) file.
3. The procedure-instance handle to the abort procedure must be
released by calling the FreeProcInstance() function once printing
is complete.
Many Windows applications allow the user to terminate the print job
through the use of a Cancel Print Job dialog box. Such a dialog box is
essentially an extension of the topic described in this article. For a
good example of how to implement a Cancel Print Job dialog box in an
application, see Chapter 15 of Charles Petzold's book, "Programming
Windows," published by Microsoft Press. Chapter 12 of the "Windows
Software Development Kit Guide to Programming" also contains an
example.
Additional reference words: 3.00 MICS3 R12