你的意思是不是打印视图在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
{
CView::OnPrepareDC(pDC,pInfo);
pDC->SetMapMode(MM_LOWETRIC);
}
{
// 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
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);后根本就打印不了,取消后又可以,大家还有什么办法没有?