我建了一个基于对话框的程序,我想点击一个按钮然后就将对话框及其上面的所有东西都打印出来我的程序如下:可打印出来的结果成为很小的一块,我想这是由于MM_TEXT模式下
Each logical unit is converted to 1 device pixel的关系,然后我试着改了一些其它模式,调整了坐标点,可是,依然不能实现“所见既所得”的效果,
大家认为该怎么办?能给我一份相关源码吗?找了n多地方,可就是找不到怎么做。。, CRect rect;
GetClientRect(&rect);
CPrintDialog dlgPrint(FALSE,PD_NOPAGENUMS,this);
if (!dlgPrint.GetDefaults ())
return FALSE; CDC dc;
dc.Attach (dlgPrint.GetPrinterDC ()); DOCINFO di;
ZeroMemory(&di,sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
CPrintInfo pi;
pi.m_rectDraw .SetRect (0,0,rect.Width (),rect.Height ()); StartDoc(dc,&di);
StartPage(dc);
Print(&dc,PRF_OWNED | PRF_CLIENT | PRF_CHILDREN );
EndPage(dc);
EndDoc(dc); DeleteDC(dc);关键,怎么才能实现屏幕看到的跟打印机打出来的一样大小?
Each logical unit is converted to 1 device pixel的关系,然后我试着改了一些其它模式,调整了坐标点,可是,依然不能实现“所见既所得”的效果,
大家认为该怎么办?能给我一份相关源码吗?找了n多地方,可就是找不到怎么做。。, CRect rect;
GetClientRect(&rect);
CPrintDialog dlgPrint(FALSE,PD_NOPAGENUMS,this);
if (!dlgPrint.GetDefaults ())
return FALSE; CDC dc;
dc.Attach (dlgPrint.GetPrinterDC ()); DOCINFO di;
ZeroMemory(&di,sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
CPrintInfo pi;
pi.m_rectDraw .SetRect (0,0,rect.Width (),rect.Height ()); StartDoc(dc,&di);
StartPage(dc);
Print(&dc,PRF_OWNED | PRF_CLIENT | PRF_CHILDREN );
EndPage(dc);
EndDoc(dc); DeleteDC(dc);关键,怎么才能实现屏幕看到的跟打印机打出来的一样大小?
解决方案 »
- 有个表头问题
- 如何用图标句柄设置生成应用程序的图标 在线等
- vc操作excel 怎么样插入一个sheet在一个指定的sheet后面
- 分要多少就多少,ActiveX手动安装问题!
- 想在一个新开的线程里只负责socket的接收和发送, 这样该怎么做???
- 2006年1月份的MVP申请开始了!
- 请问那位兄弟能用代码来设置pagefile.sys的?就象能实现WIN2000中的虚拟内存中的设置按钮中的功能.
- 这个问题谁回答了了我给200分,QQ:58624951 ,e-mail:[email protected]
- 请问各位大虾下面这段代码还能优化吗??
- >>>==================为什么我的WIN98登陆是密码要输入两次?==========<<<
- 为什么我的程序一用waveInReset就死掉?
- 求ftp 断点续传的例子
------------------------------------------------------------
AfxGetApp()->BeginWaitCursor(); UpdateData( true );
if(m_Method==0) //对角线法
{
Calculate( ) ;
DataSet( INPUT::m_column );
}
else// 方格法
CalculateRect(); mcbCalcStd->GetWindowText(tempstr);
Grade(tempstr); CDC dc;
CPrintDialog printDlg(FALSE);
if(m_printDirect==1) //是否显示打印对话框
printDlg.GetDefaults();
else
if(printDlg.DoModal()==IDCANCEL)return; //显示对话框 ,Get printer settings from user
HDC hdcPrntDC=printDlg.GetPrinterDC();
ASSERT(hdcPrntDC);
dc.Attach(hdcPrntDC); // 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;
CSize PrtSize(Info.m_rectDraw.right-Info.m_rectDraw.left,Info.m_rectDraw.bottom-Info.m_rectDraw.top );
Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZSIZE), dc.GetDeviceCaps(VERTSIZE)); Info.m_pPD->m_pd.nMaxPage=1; ASSERT(&dc);
ASSERT(&Info); OnBeginPrinting(&dc, &Info); // Call your "Init printing" funtion {
dc.StartPage(); // begin new page
Info.m_nCurPage = 1; if(m_bPRT4Check== FALSE) // 正常打印
OnPrint(&dc, &Info, 1); // Call your "Print page" function
else// 打印检修数据
MyPrint4Check(&dc, &Info); bPrintingOK = (dc.EndPage() > 0); // end page
}
OnEndPrinting(&dc, &Info); // Call your "Clean up" funtion if (bPrintingOK)dc.EndDoc(); // end a print job
else dc.AbortDoc(); // abort job.
GlobalFree(dc.m_hDC);
dc.Detach(); // detach the printer DC m_pMyEdit[0][0]->SetFocus();
m_pMyEdit[0][0]->SetSel((DWORD)0XFF00,TRUE); // m_bSaveAfterPRT; if(m_bPRT4Check==FALSE)
{
if(m_bAddAfterPrt && m_CertNo.GetLength())
{
StrNumAutoAdd(&m_CertNo);
UpdateData(FALSE);
}
}
AfxGetApp()->EndWaitCursor();
原来是要设置模式。。,更新后的源码如下:CPrintDialog dlgPrint(FALSE,PD_NOPAGENUMS,this);
if (!dlgPrint.GetDefaults ())
return FALSE; CDC dc;
dc.Attach (dlgPrint.GetPrinterDC ()); DOCINFO di;
ZeroMemory(&di,sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
CPrintInfo pi; StartDoc(dc,&di);
StartPage(dc); dc.SetMapMode(MM_ANISOTROPIC);
CSize size = CSize(800, 600);
dc.SetWindowExt(size); int xLogPixPerInch = dc.GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = dc.GetDeviceCaps(LOGPIXELSY);
long xExt = (long)size.cx * xLogPixPerInch/96 ;
long yExt = (long)size.cy * yLogPixPerInch/96 ;
dc.SetViewportExt((int)xExt, (int)yExt); Print(&dc,PRF_OWNED | PRF_CLIENT | PRF_CHILDREN );
EndPage(dc);
EndDoc(dc); DeleteDC(dc);