CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Location
    Australia
    Posts
    5

    Cancel Print Job

    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

  2. #2
    Join Date
    Jul 1999
    Location
    Moscow, Russia
    Posts
    667

    Re: Cancel Print Job

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured