自己要打印的内容放在
//模式按照0.1mm映射来处理
int xOffset=::GetDeviceCaps(hdcPrint, PHYSICALOFFSETX);
int yOffset=::GetDeviceCaps(hdcPrint, PHYSICALOFFSETY);
DOCINFO docInfo = { sizeof(DOCINFO) };
docInfo.lpszDocName = "my print test";
docInfo.lpszOutput = NULL;
docInfo.lpszDatatype = NULL;
docInfo.fwType = 0; int nMapMode=SetMapMode(hdcPrint, MM_LOMETRIC);
POINT pt;
SetViewportOrgEx(hdcPrint, xOffset, yOffset, &pt);
CFont hFont;
VERIFY(hFont.CreateFont(36,18,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,_T("宋体"))); CDC dcPrint;
dcPrint.Attach(hdcPrint);
dcPrint.StartDoc(&docInfo);
dcPrint.StartPage();
CFont *oldFont = dcPrint.SelectObject(&hFont);
dcPrint.ExtTextOut(0,0,ETO_OPAQUE,NULL,_T("记录数据"),NULL); CString strOutData;
strOutData.Format(_T("页%d 总共%d页"),nNowNumOfPage,nAllNumsOfPage);
dcPrint.ExtTextOut(1900 - strOutData.GetLength()*18,0,ETO_OPAQUE,
NULL,strOutData,NULL);//是否y为倒值 CPen penLine(PS_SOLID,0,RGB(0,0,0));
CPen *oldPen = dcPrint.SelectObject(&penLine);
//********这里应该是输出表格阿?结果没有输出?
//是不是坐标搞错了?
for (int i = 0;i<52;i++)
{
CPoint ptStart;
CPoint ptStop; ptStart.x = 1;
ptStart.y = 50*i + 70;
ptStop.x = 1899;
ptStop.y = 50*i + 70; dcPrint.MoveTo(ptStart);
dcPrint.LineTo(ptStop);
} for (i = 0;i<20;i++)
{
CPoint ptStart;
CPoint ptStop; ptStart.x = i*100 + 1;
ptStart.y = 70;
ptStop.x = i*100 + 1;
ptStop.y = 2600; dcPrint.MoveTo(ptStart);
dcPrint.LineTo(ptStop);
}//----------------------------------------
//
dcPrint.SelectObject(oldFont);
dcPrint.SelectObject(oldPen);
dcPrint.EndPage();
dcPrint.EndDoc();
hFont.DeleteObject();
penLine.DeleteObject();
dcPrint.DeleteDC(); SetMapMode(hdcPrint, nMapMode);
SetViewportOrgEx(hdcPrint, pt.x, pt.y, NULL);
//模式按照0.1mm映射来处理
int xOffset=::GetDeviceCaps(hdcPrint, PHYSICALOFFSETX);
int yOffset=::GetDeviceCaps(hdcPrint, PHYSICALOFFSETY);
DOCINFO docInfo = { sizeof(DOCINFO) };
docInfo.lpszDocName = "my print test";
docInfo.lpszOutput = NULL;
docInfo.lpszDatatype = NULL;
docInfo.fwType = 0; int nMapMode=SetMapMode(hdcPrint, MM_LOMETRIC);
POINT pt;
SetViewportOrgEx(hdcPrint, xOffset, yOffset, &pt);
CFont hFont;
VERIFY(hFont.CreateFont(36,18,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,_T("宋体"))); CDC dcPrint;
dcPrint.Attach(hdcPrint);
dcPrint.StartDoc(&docInfo);
dcPrint.StartPage();
CFont *oldFont = dcPrint.SelectObject(&hFont);
dcPrint.ExtTextOut(0,0,ETO_OPAQUE,NULL,_T("记录数据"),NULL); CString strOutData;
strOutData.Format(_T("页%d 总共%d页"),nNowNumOfPage,nAllNumsOfPage);
dcPrint.ExtTextOut(1900 - strOutData.GetLength()*18,0,ETO_OPAQUE,
NULL,strOutData,NULL);//是否y为倒值 CPen penLine(PS_SOLID,0,RGB(0,0,0));
CPen *oldPen = dcPrint.SelectObject(&penLine);
//********这里应该是输出表格阿?结果没有输出?
//是不是坐标搞错了?
for (int i = 0;i<52;i++)
{
CPoint ptStart;
CPoint ptStop; ptStart.x = 1;
ptStart.y = 50*i + 70;
ptStop.x = 1899;
ptStop.y = 50*i + 70; dcPrint.MoveTo(ptStart);
dcPrint.LineTo(ptStop);
} for (i = 0;i<20;i++)
{
CPoint ptStart;
CPoint ptStop; ptStart.x = i*100 + 1;
ptStart.y = 70;
ptStop.x = i*100 + 1;
ptStop.y = 2600; dcPrint.MoveTo(ptStart);
dcPrint.LineTo(ptStop);
}//----------------------------------------
//
dcPrint.SelectObject(oldFont);
dcPrint.SelectObject(oldPen);
dcPrint.EndPage();
dcPrint.EndDoc();
hFont.DeleteObject();
penLine.DeleteObject();
dcPrint.DeleteDC(); SetMapMode(hdcPrint, nMapMode);
SetViewportOrgEx(hdcPrint, pt.x, pt.y, NULL);
解决方案 »
- MFC 动态 Tabcontrol
- (疑难问题)CStatic的ToolTip, vc6可以,vc8不行!
- 音频处理问题
- 靠~~MFC的容器难用死啦
- 100分相送:一个基于对话框的程序,在子线程中创建了一个控件,如果创建成功,整个界面像是死掉了一样,但是子线程还在运行?请看源码
- 关于数据库查询的问题,郁闷!!
- 在SEND前检查该SOCKET是否可写?
- ado 中open 用jet 和用dsn有区别吗??在没装VC的机上程序用jet不能打开数据库 why??
- _______请问如何设置自己的浏览器?
- VC里有没有类似Delphi的TList类?
- 如何把想要保护的变量封装成一个类或者一个宏什么的方便以后调用,怎么做那?
- 新手向各位大侠请教一些问题,请大侠进来瞅瞅吧
(当前窗口原点在左上角,绘图区为第四象限。若想使用正值,需调用SetWindowOrgEx将原点移至左下角)