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

    Printing question



    How can I tell my app, that I want to have a print header on each page.

    I have an EditView derived class with text in it, on printing the 1st

    on the page should be a user defined header.

    How can i realise it?


    thanks


    thomas

  2. #2
    Join Date
    Apr 1999
    Posts
    383

    Re: Printing question



    Override OnPrint and print your header text at the top of the CRect given in the CPrintInfo structure:

    pInfo->m_rectDraw.

    This is the rectangle that the rest of the page will be printed into, so calculate the total height of your header and

    add that to the top of the drawing rectangle, then call the base class method, so that the page lines appear under the

    heading. Something like this:

    void MyCEditView::OnPrint(CDC* pDC, CPrintInfo* pInfo)

    {

    ASSERT_VALID(this);

    ASSERT_VALID(pDC);

    ASSERT(pInfo != NULL);

    ASSERT(pInfo->m_bContinuePrinting);

    // Prepare header font here or make it a member variable

    CFont* pOldFont = NULL;

    pOldFont = pDC->SelectObject(headerFont);

    int oldBkMode = pDC->SetBkMode(TRANSPARENT);

    // Do your header printing into pInfo->m_rectDraw here

    // and calculate the TotalHeaderHeight:

    int totalHeaderHeight = PrintHeaderInRect(pDC, pInfo->m_rectDraw);

    pDC->SetBkMode(oldBkMode);

    if (pOldFont != NULL)

    pDC->SelectObject(pOldFont);

    pInfo->m_rectDraw.top += totalHeaderHeight;


    CEditView::OnPrint(pDC, pInfo);

    }



    Dave

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