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();
}
}