HRESULT CSTEditorDoc::AttachPrinterDC (CDC * pDC)
{
    // prepare printing
    CPrintDialog printDlg(FALSE);  // Instantiate a CPrintDialog object.

    // Retrieve the current printer defaults from the Windows .ini file
    // as necessary, or uses the last printer configuration set by the
    // user in Print Setup.
    CSTEditorApp* pApp = dynamic_cast<CSTEditorApp *>(AfxGetApp());

    pApp->DevModeChange((LPTSTR)(LPCTSTR)GetPrinterName());

    if (!pApp->GetPrinterDeviceDefaults (&printDlg.m_pd)) 
	{ 
        // Fails to create a printer device context for printing because
        // no printer is being installed. Bring up dialog box to alert the
        // users that they need to install a printer.  This step is optional.
        if (pApp->DoPrintDialog (&printDlg) != IDOK)
		{
            return (E_FAIL);
        }
    }

    // Creates a printer DC from the DEVMODE and DEVNAMES structures.
    if (printDlg.CreatePrinterDC () == NULL) 
    {
        return (E_FAIL);
    }

    // A printer device context (DC) has been created.
    // Attach it to a CDC object. The DC is deleted when the CDC
    // object goes out of scope.
    pDC->Attach (printDlg.GetPrinterDC ()); 
    return (S_OK);
}
Пример #2
0
void CPredView::OnFilePrint()
{
	CDC dc;
	CPrintDialog printDlg(false);
	if(printDlg.DoModal()==IDCANCEL)
		return;
	dc.Attach(printDlg.GetPrinterDC());
	dc.m_bPrinting=true;

	DOCINFO di;
	::ZeroMemory(&di,sizeof(DOCINFO));
	di.cbSize=sizeof(DOCINFO);
	di.lpszDocName="FCC Prediction";
	

	bool bPrintingOK=dc.StartDocA(&di);
	CPrintInfo info;
	info.m_rectDraw.SetRect(0,0,dc.GetDeviceCaps(HORZRES),dc.GetDeviceCaps(VERTRES));
	
	
	//OnPreparePrinting(&info);
	OnBeginPrinting(&dc,&info);
	OnPrint(&dc,&info);
	OnEndPrinting(&dc,&info);
	
	if(bPrintingOK)
		dc.EndDoc();
	else
		dc.AbortDoc();
	dc.Detach();
}
Пример #3
0
void AMPWebView::slotPrintRequest( QWebFrame *frame )
{
    if ( !frame ) return;
    _printFrame=frame;
    QPrintDialog printDlg( this );
    connect( &printDlg, SIGNAL( accepted( QPrinter* ) ), this, SLOT( slotPrintFrame( QPrinter* ) ) );
    printDlg.exec();
}
Пример #4
0
void CHallQueFrontView::OnPrintset()
{
	// TODO: 在此添加命令处理程序代码
	CPrintSetDlg printDlg(this);
	if(IDOK == printDlg.DoModal())
	{
		theApp.m_Controller.ReFlushPrintInfoTable();
	}
}
Пример #5
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();
}