CSDN博客

img bluebohe

打印的简单实现,以及更改打印设置

发表于2003/10/29 17:54:00  1243人阅读

 

void PrintTest()

{

         CPrintDialog dlg(FALSE, PD_ALLPAGES | PD_COLLATE | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE);

         if(dlg.GetDefaults())

         {

                  DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(dlg.m_pd.hDevMode);

                  pDevMode->dmOrientation=DMORIENT_PORTRAIT;//改为纵向打印

                  ::GlobalUnlock(dlg.m_pd.hDevMode);

                  

 

                  DOCINFO di;

                 memset( &di, 0, sizeof(DOCINFO) );

                  di.cbSize = sizeof(DOCINFO);

                  di.lpszDocName = "Printing Test";

                  di.lpszOutput = (LPTSTR) NULL;

                  di.fwType = 0;

                   HDC hDC=dlg.CreatePrinterDC();

                   CDC dc;

                  dc.Attach(hDC);

                  dc.StartDoc(&di);

                  dc.StartPage();

                  dc.MoveTo(0,0);

                  dc.LineTo(1000,1000);

                  dc.EndPage();

                  dc.EndDoc(); 

                  dc.DeleteDC();

         }

}

0 0

相关博文

我的热门文章

img
取 消
img