Any Windows-based application that supports printing should provide an abort procedure and a modeless dialog box that allow a user to cancel a print job. The abort procedure for the sample application contains a message loop that retrieves messages for the modeless dialog box.
BOOL CALLBACK AbortProc(HDC hdc, int nCode)
{
MSG msg;
// Retrieve and remove messages from the thread's message queue.
while (PeekMessage((LPMSG) &msg, (HWND) NULL, 0, 0, PM_REMOVE))
{
// Process any messages for the Cancel dialog box.
if (!IsDialogMessage(hdlgCancel, (LPMSG) &msg))
{
TranslateMessage((LPMSG) &msg);
DispatchMessage((LPMSG) &msg);
}
}
// Return the global bPrint flag (which is set to FALSE if the
// user presses the Cancel button).
return bPrint;
}
For Win16-based applications, this procedure must be exported in the application's module-definition (.DEF) file.