Aborting Print Process
Just wondering...I have a SDI application where I load a lot of data into a buffer in OnBeginPrinting(). Since it can take a while to preload the data I implemented a progress meter from CProgressDlg. If the user clicks the Cancel button on the progress dialog, all the memory is cleaned up that had been used. The only other thing that I want to do is with OnBeginPrinting() exit the printing cycle altogether. The code below calls LoadSummaryData() that returns false is the Cancel button was hit.
void CPavementView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
if (!LoadSummaryData())
return;
CFormView::OnBeginPrinting(pDC, pInfo);
}
[685 byte] By [
wrv369] at [2007-11-18 19:16:59]

# 1 Re: Aborting Print Process
If you take a look at the standard MFC print code in:
C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\MFC\SRC\VIEWPRNT.CPP(131):void CView::OnFilePrint()
(or your equavalent location).
You will see that MFC does not allow an abort to be given from the OnBeginPrinting() function. Also, the dialog box displayed so the user can abort the printis not available until after OnBeginPrinting() is called.
Your would probably be better of putting you intialisation code in the OnPreparePrinting() function, as you can return an abort code from there.