12.6 Canceling a Print Operation

Your application should always give the user a chance to cancel a lengthy printing operation. A common way to do this is to display a dialog box when the printing operation begins. During printing, the user can click the dialog box's Cancel button to cancel the print operation.

To provide a dialog box from which the user can cancel a printing operation, follow these steps:

1.In your application's resource-definition (.RC) file, define a modeless dialog box from which the user can cancel a print operation.

2.In your application source code, provide a dialog box procedure that drives the dialog box.

3.In your application source code, provide a print-canceling function that processes messages for the dialog box.

4.Modify your application's printing procedure so that it displays the dialog box and correctly processes messages.

5.Export the dialog box procedure and print-canceling function in the module-definition (.DEF) file.