I have an array of strings in the doc class that I want to print
When there are Npages to print, the first page is sent to the printer Npages times
What am I doing wrong? The (too lengthy) code in the View class is
BOOL CTestView::OnPreparePrinting(CPrintInfo* pInfo
{
pInfo->SetMaxPage(1); // set default valu
pInfo->m_nCurPage = 1; // initializ
BOOL bRet = DoPreparePrinting(pInfo)
pInfo->m_nNumPreviewPages = 2
return bRet;
void CTestView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo
{
// get printed character height and width
TEXTMETRIC tm
pDC->GetTextMetrics( &tm )
m_nPrintCharHeight = tm.tmHeight
m_nPrintCharWidth = tm.tmAveCharWidth
// Get number of characters per line
int nPageWidth = pDC->GetDeviceCaps( HORZRES )
m_nPageWidth = nPageWidth/m_nPrintCharWidth
// Get number of lines per page (with and w/out title on each page)
int nPageHeight = pDC->GetDeviceCaps( VERTRES )
int nPrintLinesPerPage = nPageHeight/m_nPrintCharHeight
m_nPrintableLinesPerPage = nPrintLinesPerPage - 15
// Determine number of total pages in document
int nLines = GetDocument()->getIFinal()
int nPages = 1 + (int)(nLines/m_nPrintableLinesPerPage)
if(nPages <1) nPages = 1
pInfo->SetMaxPage(nPages)
pInfo->m_nCurPage = 1
return
}
void CTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/
{ return;
// ************************************************** ******OnPrin
void CTestView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
char *st
int l
int y=50
CTestDoc* pDoc = GetDocument()
// Determine the part of the document to print on this page
int nListInx = ( pInfo->m_nCurPage -1)*m_nPrintableLinesPerPage
int nListEnd = GetDocument()->getIFinal()
if(nListEnd > nListInx + m_nPrintableLinesPerPage
{ nListEnd = nListInx + m_nPrintableLinesPerPage;
for (l=nListInx;l<nListEnd;l++
{
pDC->SetTextAlign( TA_LEFT)
st = pDoc->getStrNumber(l); // The testDoc class contains an array of strings
pDC->TextOut(0, y, st)
y += m_nPrintCharHeight
CView::OnPrint(pDC,pInfo)
}