Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all,

I've got a C++ app which prints up to four pages. Under VC++6 you could specify From and To pages in the print dialog, but in VS2005, it always prints all of the pages even if you specify From=1 and To=1.

I've tried patching the OnPrint() function by adding
if ( pInfo->m_nCurPage == pInfo->GetToPage() )
{
    pInfo->m_bContinuePrinting = false;
}

at the bottom but it still prints all the pages.

Googling suggests that it's a bug in VS2005, any ideas how to stop after the correct number of pages if it doesn't stop printing when I set pInfo->m_bContinuePrinting to false?
Posted

1 solution

Fixed it, it needs to go in CView::OnPrepareDC(), and stop the printout if we have gone past the To page:
void CMyView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
    CView::OnPrepareDC(pDC, pInfo);
	
    if ( pInfo )
    {
        if ( pInfo->m_nCurPage > pInfo->GetToPage() )
            pInfo->m_bContinuePrinting = FALSE;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900