本文介绍了在没有Doc/View的情况下打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好时光!

我打印窗口,但不打印此窗口菜单.我在哪里犯错?

good time !

I print window, but not print menu this window. Where i do mistake?

void CTestApp::OnFilePrint()
{
        CPrintDialog cp(FALSE);
	if (cp.DoModal)==IDOK)
        {
	  CPrintInfo Info;
	  CDC PrintDC;
	  PrintDC.Attach(cp.GetPrinterDC());
	  DOCINFO infStru;
	  ::ZeroMemory (&infStru, sizeof (DOCINFO));

	 infStru.cbSize = sizeof (DOCINFO);
	 infStru.lpszOutput=NULL;

	 if (PrintDC.StartDoc(&infStru )==-1)
		AfxMessageBox(_T("Error StartDoc"),NULL,NULL);

	 PrintDC.StartPage();
	 PrintDC.SetMapMode(MM_ANISOTROPIC);
	 CClientDC dcScreen(NULL);

	 int ixd = dcScreen.GetDeviceCaps(LOGPIXELSX);
	 int iyd = dcScreen.GetDeviceCaps(LOGPIXELSY);

	 // get the printer''s pixel resolution
	 int ixp = PrintDC.GetDeviceCaps(LOGPIXELSX);
	 int iyp = PrintDC.GetDeviceCaps(LOGPIXELSY);

         PrintDC.SetMapMode(MM_ANISOTROPIC);
	 PrintDC.SetWindowExt(ixd, -iyd);
	 PrintDC.SetViewportExt(ixp, -iyp);

	 m_pMainWnd->Print(&PrintDC, PRF_OWNED | PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN);

	 AfxMessageBox(_T("printing"),NULL,NULL);

	 if (PrintDC.EndPage()<0)
		AfxMessageBox(_T("Error EndPage"),NULL,NULL);
	 if (PrintDC.EndDoc()==0)
		AfxMessageBox(_T("Error EndDoc"),NULL,NULL);
	 PrintDC.Detach();
	}
}

推荐答案


这篇关于在没有Doc/View的情况下打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 21:29
查看更多