Winapi Startdoc Cannot Detect User Chose Cancel in Saveas Dialog
When the User Responds to the Print Dialog Invoked by Startdoc() Function, by Pressing Cancel Button, Startdoc() Returns False and the Program Cancels the...
When the user responds to the Print dialog invoked by StartDoc() function, by pressing Cancel button, StartDoc() returns false and the program cancels the print job.
However, when the user chooses pdf printer driver, it can open another dialog for naming the pdf file. If the user chooses Cancel at this stage, StartDoc() does not return false to the calling function. The program actually performs all the printing process except a file is not created. How to detect the user selected Cancel in Saveas dialogbox of the printer driver in order to avoid lengthy printing process.
Is there a way to detect the user selected Cancel in the later Saveas dialog.
Below is a sample code:
PRINTDLGEX Printdlgex ;
HDC PrintDC = GetPrinterDC (hwnd,&Printdlgex) ;
if (! PrintDC)
return false ;
static DOCINFO di = { sizeof (DOCINFO), "My Program", NULL } ;
if (StartDoc (PrintDC,&di) > 0) {
if (StartPage (PrintDC) > 0) {
// Lengthy Printing process
} /* if (StartPage (PrintDC) > 0) */
} /* if (StartDoc (PrintDC,&di) > 0) */