The AbortDlg dialog box procedure provides support for the AbortDlg dialog box that appears while the printing is in progress. The AbortProc function processes messages intended for the AbortDlg dialog box and cancels the printing operation if the user has requested it.
The AbortDlg dialog box procedure sets the input focus and sets the name of the file being printed. It also sets the fAbort variable to TRUE if the user clicks the Cancel button. To create this dialog box procedure, add the following statements to the C-language source file:
int FAR PASCAL AbortDlg(hDlg, msg, wParam, lParam)
HWND hDlg;
UINT msg;
WPARAM wParam;
LPARAM lParam;
{
switch (msg) {
case WM_COMMAND:
return (fAbort = 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 box procedure or to other windows in the application. If one of these messages causes the AbortDlg dialog box procedure to set the fAbort variable to TRUE, the AbortProc function returns this value, directing Windows to stop the printing operation. To create this function, add the following statements to the C-language source file:
int FAR PASCAL AbortProc(hdcPrinter, Code)
HDC hdcPrinter; /* for multiple printer display contexts */
int Code; /* printing status */
{
MSG msg;
while (!fAbort && PeekMessage(&msg, NULL, NULL, NULL, TRUE))
if (!IsDialogMessage(hAbortDlgWnd, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (!fAbort);
}