我做了一个基于对话框的报表系统。表格是用CDC画的,画的时候是按照A4的纸画的。我用A4的打印机打印正确,可是我用A3的打印机(打印纸设置成A4)打印出来的结果总是按照A3的纸打印的,字的大小没有改变,就是整个排版全是A3的,所以打印出来的A4纸上只能显示部分,请问有什么办法没有?在线等待!

解决方案 »

  1.   

    SetMapMode,用的是什么方式, 不要设成MM_TEXT试试
      

  2.   

    我说的A3打印机是指能打A3纸的打印机,A4打印机是指只能打A4纸及其更小纸的打印机
      

  3.   

    http://expert.csdn.net/Expert/topic/1934/1934208.xml?temp=.6206476
      

  4.   

    OnPrepareDC(....)
    {
    CView::OnPrepareDC(pDC,pInfo);
    pDC->SetMapMode(MM_LOWETRIC);
    }
      

  5.   

    你的意思是不是打印视图在A3打印机被整体放大了?这一定是你的映射模式的问题了对了,你是怎么获得打印的DC的?void OnBeginPrinting(CDC *pDC, CPrintInfo* pInfo)
    {
        // maybe pre cache some pens or brushes, or modify the
        // properties of the DC
    }void OnPrint(CDC *pDC, CPrintInfo* pInfo)
    {
        // Do your drawing/printing exactly as you would in a
        // CView::OnDraw function. The CPrintInfo structure
        // will give you the bounds and the current page number
    }void OnEndPrinting(CDC *pDC, CPrintInfo* pInfo)
    {
        // Clean up pens or brushes, or restore the DC
    }
    The Printing code
    void CMyDialog::Print() 
    {
        CDC dc;
        CPrintDialog printDlg(FALSE);    if (printDlg.DoModal() == IDCANCEL)     // Get printer settings from user
            return;    dc.Attach(printDlg.GetPrinterDC());     // Get and 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));    OnBeginPrinting(&dc, &Info);            // Call your "Init printing" function
        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
        }
        OnEndPrinting(&dc, &Info);              // Call your "Clean up" function    if (bPrintingOK)
            dc.EndDoc();                        // end a print job
        else
            dc.AbortDoc();                      // abort job.    dc.DeleteDC();                          // delete the printer DC
    }About Chris Maunder
      

  6.   

    //调整打印方向
    pDM->dmOrientation=DMORIENT_LANDSCAPE;//DMORIENT_LANDSCAPE(横向)|DMORIENT_PORTRAIT(纵向);
    //设置打印机分辨率
    pDM->dmPrintQuality=1200;
    //联结打印DC,m_hDC是定义为HDC m_hDC的类成员变量
    m_hDC=dlgPrint.CreatePrinterDC();
    //设置打印纸大小
    pDM->dmPaperSize = DMPAPER_USER; //设定为自定义纸张尺寸 
        pDM->dmFields |= DM_PAPERSIZE; //允许重新设置纸张大小 
        pDM->dmPaperLength = 2970; //设定纸长为297毫米 
    pDM->dmPaperWidth=2100;
        ResetDC(m_hDC,pDM); //使设置的参数发挥作用 
    //m_DC是定义为CDC m_DC的类成员变量
    if(!m_DC.Attach(m_hDC))
    return FALSE;
    //设置打印标志
    m_DC.m_bPrinting=TRUE;
    //根据打印机分辨率建立打印字体,得到每英寸点数
    short cxInch=m_DC.GetDeviceCaps(LOGPIXELSX);
    short cyInch=m_DC.GetDeviceCaps(LOGPIXELSY);
    程度大概就是这样的,可是我添加SetMapMode(MM_LOWETRIC);后根本就打印不了,取消后又可以,大家还有什么办法没有?