15,979
社区成员
发帖
与我相关
我的任务
分享
void ***::OnPrintreport()
{
// TODO: Add your control notification handler code here
UpdateData(true);
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
CDemoDoc* pDoc= (CDemoDoc*)pChild->GetActiveDocument();
PRINTDLG pd;
pd.lStructSize = sizeof(PRINTDLG);
pd.Flags = PD_RETURNDC;
//pd.hDC = NULL;
pd.hwndOwner = NULL;
pd.hInstance = NULL;
pd.nMaxPage = 1;
pd.nMinPage = 1;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nCopies = 1;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
// PrintDlg(&pd);
if(!PrintDlg(&pd)) return ;
// ASSERT(pd.hDC!=NULL);
int nHorRes = GetDeviceCaps(pd.hDC, HORZRES);
int nVerRes = GetDeviceCaps(pd.hDC, VERTRES);
TEXTMETRIC tm;
GetTextMetrics(pd.hDC, &tm);
int nCharHeight = tm.tmHeight;
int nCharWidth = tm.tmAveCharWidth;
int nXMargin = 2;
int nYMargin = 2;
DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "*****表";
di.lpszOutput = (LPTSTR) NULL;
di.lpszDatatype = (LPTSTR) NULL;
di.fwType = 0;
StartDoc(pd.hDC, &di);
StartPage(pd.hDC);
// int oriy=-100,space=-40,space1=-36;
// HFONT afont1;
HFONT afont1,afont2;
int a=SetMapMode(pd.hDC,MM_LOENGLISH);
// CString str;
HPEN pen1,pen2,pen3;
afont1=CreateFont(-35,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,"宋体");
CTime m_time;
CString strTime;
m_time = CTime::GetCurrentTime();
strTime = m_time.Format("20%y年%m月%d日");
SelectObject(pd.hDC,afont2);
TextOut(pd.hDC,620,-60,strTime,strlen(strTime));
EndPage(pd.hDC);
EndDoc(pd.hDC);
//打印结束
DeleteDC(pd.hDC);
}