コード例 #1
0
void CvSqlQueryLowerView::DoFilePrint()
{
	CDC dc;
	CPrintDialog printDlg(FALSE);

	if (printDlg.DoModal() == IDCANCEL)         // Get printer settings from user
		return;

	dc.Attach(printDlg.GetPrinterDC());         // Attach a printer DC
	dc.m_bPrinting = TRUE;

	CString strTitle;                           // Get the application title
	strTitle.LoadString(AFX_IDS_APP_TITLE);

	DOCINFO di;                                 // Initialise print document details
	::ZeroMemory (&di, sizeof (DOCINFO));
	di.cbSize = sizeof (DOCINFO);
	di.lpszDocName = strTitle;

	BOOL bPrintingOK = dc.StartDoc(&di);        // Begin a new print job
	// Get the printing extents and store in the m_rectDraw field of a  CPrintInfo object
	CPrintInfo Info;
	Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));
	Info.m_bPreview = TRUE;

	OnBeginPrinting(&dc, &Info);                // Call your "Init printing" funtion
	if (m_nPageWidth > Info.m_rectDraw.Width())
		m_nPageWidth = Info.m_rectDraw.Width();
	if (m_nPageHeight > Info.m_rectDraw.Height())
		m_nPageHeight = Info.m_rectDraw.Height();

	while (bPrintingOK)
	{
		dc.StartPage();                         // begin new page
		PrintPageHeader(&dc, Info.m_nCurPage);  // updates m_nHeaderHeight
		PrintPageFooter(&dc, Info.m_nCurPage);  // updates m_nFooterHeight

		ASSERT (m_nHeaderHeight >= 0);
		ASSERT (m_nFooterHeight >= 0);

		PrintPage(&dc, Info.m_nCurPage);
		Info.m_nCurPage++;
		dc.EndPage();
		bPrintingOK = ((int)Info.m_nCurPage > m_nbPrintPage) ? FALSE: TRUE;
	}

	OnEndPrinting(&dc, &Info);
	dc.EndDoc();
	dc.Detach();
}
コード例 #2
0
void CvSqlQueryLowerView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	// Pre-adjust width and height
	if (m_nPageWidth > pInfo->m_rectDraw.Width())
		m_nPageWidth = pInfo->m_rectDraw.Width();
	if (m_nPageHeight > pInfo->m_rectDraw.Height())
		m_nPageHeight = pInfo->m_rectDraw.Height();

	PrintPageHeader(pDC, pInfo->m_nCurPage);  // updates m_nHeaderHeight
	PrintPageFooter(pDC, pInfo->m_nCurPage);  // updates m_nFooterHeight

	ASSERT (m_nHeaderHeight >= 0);
	ASSERT (m_nFooterHeight >= 0);

	PrintPage(pDC, pInfo->m_nCurPage);
}
コード例 #3
0
ファイル: WorkspaceView.cpp プロジェクト: malpharo/AiPI
void CWorkspaceView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	CFont font;

	CWorkspaceTabDoc* pDoc = GetDocument();
	m_nPage = pInfo->m_nCurPage; // en beneficio de PrintPageFooter
    
	// fuente de 14 puntos, tamaño fijo
	font.CreateFont(-30, 0, 0, 0, 400, FALSE, FALSE,
	                0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
	                CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
	                DEFAULT_PITCH | FF_MODERN, _T("Arial"));
	                // Courier New es una fuente TrueType 
    CFont* pOldFont = (CFont*) (pDC->SelectObject(&font));
    
        
	PrintPageHeader(pDC);
	PrintPageFooter(pDC); 
	
	pDC->SelectObject(pOldFont);
	
	
	WORKSPACEMAINVIEW::OnPrint(pDC, pInfo);
}