Thomas
March 31st, 1999, 06:12 AM
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
Dave Lorde
March 31st, 1999, 10:28 AM
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