You need to create the AbortDlg and AbortProc functions to support the printing process. The AbortDlg dialog function provides support for the AbortDlg dialog box that appears while the printing is in progress. The dialog box lets the user cancel the printing operation if necessary. The AbortProc function processes messages intended for the AbortDlg dialog box and terminates the printing operation if the user has requested it.
The AbortDlg dialog function sets the input focus and sets the name of the file being printed. It also sets the bAbort variable to TRUE if the user chooses the Cancel button. Add the following statements to the C-language source file:
int FAR PASCAL AbortDlg(hDlg, msg, wParam, lParam)
HWND hDlg;
unsigned msg;
WORD wParam;
LONG lParam;
{
switch(msg) {
case WM_COMMAND:
return(bAbort = TRUE);
case WM_INITDIALOG:
SetFocus(GetDlgItem(hDlg, IDCANCEL));
SetDlgItemText(hDlg, IDC_FILENAME, FileName);
return(TRUE);
}
return (FALSE);
}
The AbortProc function checks for messages in the application queue and dispatches them to the AbortDlg dialog function or to other windows in the application. If one of these messages causes the AbortDlg dialog function to set the bAbort variable to TRUE, the AbortProc function returns this value, directing Windows to stop the printing operation. Add the following statements to the C-language source file:
int FAR PASCAL AbortProc(hPr, Code)
HDC hPr; /* for multiple printer display contexts */
int Code; /* printing status */
{
MSG msg;
while(!bAbort && PeekMessage(&msg, NULL, NULL, NULL, TRUE))
if(!IsDialogMessage(hAbortDlgWnd, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(!bAbort);
}