我做了一个基于对话框的报表系统。表格是用CDC画的,画的时候是按照A4的纸画的。我用A4的打印机打印正确,可是我用A3的打印机(打印纸设置成A4)打印出来的结果总是按照A3的纸打印的,字的大小没有改变,就是整个排版全是A3的,所以打印出来的A4纸上只能显示部分,请问有什么办法没有?在线等待!
解决方案 »
- windows完成端口,如何获得单纯的超时事件?
- 资源泄漏
- 我想把double类型的数组写入一个txt文件中,该用什么函数,如何操作?
- 求助:如何得到CString的ASCII码?
- 请问有了Xtreme Toolkit Pro的源代码就可以不用他们的dll,直接把源文件编译进自己的工程吗
- 高手指点 在WINDOWS下怎么设置网卡的混杂模式
- mp3文件的数据格式是怎样的?
- 今天没事到人才交流会上转了转,啊,行情变化大了,要软件网络方面的公司大大少了,不敢想象过几年会是什么样子
- RegisterHotKey失败,调用 GetLastError 返回1004
- 如何对保护制定字符的网址进行处理
- 一个运行时的错误,送分求助
- 请教设备接口
{
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);后根本就打印不了,取消后又可以,大家还有什么办法没有?