Click to See Complete Forum and Search --> : Cancel Print Job


Russell Robinson
September 19th, 1999, 11:46 PM
Does anyone know how the application can cancel a print job after
OnBeginPrinting has been called by the framework?

The doco for CDC::AbortDoc is self-contradictory - and it doesn't work.
Setting CPrintInfo::m_bContinuePrinting to FALSE also doesn't cancel the job.


Russell Robinson
Software Developer

Oleg Lobach
September 21st, 1999, 02:55 AM
Hi,
CPrintInfo::m_bContinuePrinting should help. But to work properly it should be set to FALSE in overriden CView::OnPrepareDC after call to base implementation,which as you can see below also set m_bContinuePrinting:

void CView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
ASSERT_VALID(pDC);
UNUSED(pDC); // unused in release builds

// Default to one page printing if doc length not known
if (pInfo != NULL)
pInfo->m_bContinuePrinting =
(pInfo->GetMaxPage() != 0xffff || (pInfo->m_nCurPage == 1));
}



To make sure that it's should work look at CView::OnFilePrint() source:

///.......
{ //......
OnPrepareDC(&dcPrint, &printInfo);

// check for end of print
if (!printInfo.m_bContinuePrinting)
break;
///..........
}




Another way - set CPrintInfo::m_nCurPage to 0 and use CPrintInfo::SetMaxPage(1) before call to CView::OnPrepareDC.

Hope this helps,
Oleg.