你好,能不能把你那个对话框中的打印代码给我看看,我只要求能打印出字符即可,谢谢

解决方案 »

  1.   

    打印用CBitmap较方便
    CBitmap* m_pBmp;
    HDC hdc = CreateCompatibleDC(hPDC);
    SelectObject(hdc,*m_pBmp);
    if(StartDoc(hPDC,&di) > 0)
    {
    StretchBlt(hPDC,x,y,5*m_pBmp->Width(),5*m_pBmp->Height(),hdc,0,0,m_pBmp->Width(),m_pBmp->Height(),SRCCOPY);
    }
    else
    MessageBox("执行打印作业时产生错误,可能是打印机没准备好。","错误",MB_OK|MB_ICONWARNING);
    EndDoc(hPDC);
    换页:
    CPrintInfo Info;
    Info.m_rectDraw.SetRect(0,0, 
                                dc.GetDeviceCaps(HORZRES), 
                                dc.GetDeviceCaps(VERTRES));    OnBeginPrinting(&dc, &Info);                
    for (UINT page = Info.GetMinPage(); 
             page <= Info.GetMaxPage() && bPrintingOK; 
             page++)
        {
            dc.StartPage();                         // begin new page
            Info.m_nCurPage = page;
            OnPrint(&dc, &Info);                    // Call your "Print page" function
            bPrintingOK = (dc.EndPage() > 0);       // end page
        }