In your application source code, you must provide a dialog box procedure for the Abort dialog box. The procedure should process the messages WM_INITDIALOG and WM_COMMAND. So that the user can choose the Cancel button by using the keyboard, the procedure takes control of the input focus when the dialog box is initialized. The dialog box procedure then ignores all messages until a WM_COMMAND message appears. Command input causes the function to destroy the window and set the fAbort flag to TRUE. The following example shows the required statements for the dialog box procedure:
int FAR PASCAL AbortDlg(hWnd, msg, wParam, lParam)
HWND hWnd;
UINT msg;
WPARAM wParam;
LPARAM lParam;
{
if (msg == WM_COMMAND) {
if (wParam == IDCANCEL) {
/* The user has canceled the print operation. */
fAbort = TRUE; /* global flag */
EndDialog(hWnd, wParam);
return TRUE;
}
}
else if (msg == WM_INITDIALOG) {
/* Set the input focus for user input. */
SetFocus(hWnd);
return TRUE;
}
return FALSE;
}