关于用CDC打印的问题,大家快帮忙
不知为何,我用CDC类打印设置的字体无效。代码如下:
CDC printhkd;
CPrintDialog printDlg(FALSE);
if (printDlg.DoModal() == IDCANCEL)
return;
printhkd.Attach(printDlg.GetPrinterDC());
printhkd.m_bPrinting = TRUE;
CString jh;
DOCINFO docinfo;
static char szMsg[]="文档名";
docinfo.cbSize=strlen(szMsg);
docinfo.lpszDocName=szMsg;
docinfo.lpszOutput=NULL;
zt=printhkd.GetCurrentFont();
zt->GetLogFont(&curLogFont);
//执行到此时curLogFont.lfHeight,lfWidth,lfWeight都为0,不知为何。
curLogFont.lfWidth=100;
curLogFont.lfHeight=100;
//上两行为设置新的字体大小,可是不论宽度和高度定为多少,打印出来的
//字体都没变,不知是哪儿的问题。
newfont.CreateFontIndirect(&curLogFont);
printhkd.SelectObject(&newfont);
printhkd.StartDoc(&docinfo);
printhkd.StartPage();
i=TextOut(printhkd.m_hDC,10,10,"zhm",3);
printhkd.EndPage();
printhkd.EndDoc();
DeleteDC(hPrinthkd);
另外,因为我没有在程序创建是选中打印,只在程序的对话框中需要打印,这样的话我如何定义纸张大小,CDC类中好象没有定义纸张大小的方法。请各位大虾帮忙。