www.pudn.com > PressMonitor_q.zip > FaultView.cpp


// FaultView.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Monitor.h" 
#include "FaultView.h" 
#include "MonitorDoc.h" 
#include "Hint.h" 
#include "DBManageDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
#define NUMper			0.08 
#define TYPEper			0.16 
#define TIMEper			0.35 
#define NOTEper			0.40 
///////////////////////////////////////////////////////////////////////////// 
// CFaultView 
 
IMPLEMENT_DYNCREATE(CFaultView, CListView) 
 
CFaultView::CFaultView() 
{ 
	m_nItemIndex=0; 
} 
 
CFaultView::~CFaultView() 
{ 
	if(m_pImageList!=NULL) delete m_pImageList; 
} 
 
 
BEGIN_MESSAGE_MAP(CFaultView, CListView) 
	//{{AFX_MSG_MAP(CFaultView) 
	ON_COMMAND(ID_DB_MANAGE, OnDbManage) 
	//}}AFX_MSG_MAP 
	ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview) 
 
END_MESSAGE_MAP() 
 
UINT CFaultView::m_ColumnLabelID [NUM_COLUMNS] =  
{ 
	IDS_TABLE_HEAD_NAME, 
	IDS_TABLE_HEAD_TIME, 
	IDS_TABLE_HEAD_NOTE, 
}; 
 
int CFaultView::m_ColumnFormat [NUM_COLUMNS] =  
{ 
	LVCFMT_CENTER, LVCFMT_CENTER, LVCFMT_CENTER 
//	LVCFMT_LEFT,LVCFMT_LEFT,LVCFMT_LEFT 
}; 
///////////////////////////////////////////////////////////////////////////// 
// CFaultView drawing 
 
void CFaultView::OnDraw(CDC* pDC) 
{ 
	CDocument* pDoc = GetDocument(); 
	// TODO: add draw code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFaultView diagnostics 
 
#ifdef _DEBUG 
void CFaultView::AssertValid() const 
{ 
	CListView::AssertValid(); 
} 
 
void CFaultView::Dump(CDumpContext& dc) const 
{ 
	CListView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CFaultView message handlers 
 
void CFaultView::OnInitialUpdate()  
{ 
	CListView::OnInitialUpdate(); 
	 
	CListCtrl	&lc	= GetListCtrl(); 
	int Column; 
	LV_COLUMN		LVColumn;		// column info of one column in list control 
 
	CMonitorDoc	*pDoc = (CMonitorDoc*) GetDocument(); 
	pDoc->m_bUpdateView=false; 
	pDoc->m_bAddItemflag[0] = true; 
	pDoc->m_bAddItemflag[1] = true; 
 
	DWORD dwStyle = ListView_GetExtendedListViewStyle(GetListCtrl()); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SUBITEMIMAGES | 
							LVS_EX_HEADERDRAGDROP | LVS_EX_TRACKSELECT; 
	ListView_SetExtendedListViewStyle (GetListCtrl(),dwStyle); 
 
 
	lc.DeleteAllItems ();// regular cleanup 
 
	m_pImageList = new CImageList(); 
	m_pImageList->Create(IDB_FAULT, 16, 1, RGB(0,0,0)); 
	GetListCtrl().SetImageList(m_pImageList, LVSIL_SMALL); 
	 
	//initialize the columns (insert columns) 
	m_ColumnWidth [COL_NAME      ] = 150; 
	m_ColumnWidth [COL_TIME		 ] = 200; 
	m_ColumnWidth [COL_NOTE      ] = 400; 
 
	// set header and format for all visible columns 
	LVColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 
 
	{ 
		for (Column = 0; (Column < NUM_COLUMNS); Column++) 
		{ 
			CString		HeaderString; 
		 
			// fill header data 
			HeaderString.LoadString (m_ColumnLabelID[Column]); 
 
			LVColumn.iSubItem	= Column; 
			LVColumn.pszText	= (LPTSTR) (LPCTSTR) HeaderString; 
			LVColumn.cx			= m_ColumnWidth [Column]; 
			LVColumn.fmt		= m_ColumnFormat [Column]; 
			lc.InsertColumn (Column, &LVColumn); 
		} 
	} 
 
	SetFocus (); 
	lc.SetItem(0, 0, LVIF_STATE, NULL, 0, LVIS_FOCUSED , LVIS_FOCUSED, 0); 
	 
//	pDoc->UpdateAllViews(NULL,HINT_DB_OPENED); 
 
	//if(!pDoc->m_bDBOpen) 
	//		pDoc->InitDB(); 
	 
	if (!pDoc->m_bDBOpen) { 
		pDoc->UpdateAllViews(NULL,HINT_DATA_RENEW); 
		return; 
	}	 
	m_nRecordCount=pDoc->m_RecordSet.GetRecordCount(); 
	if (m_nRecordCount>=1) { 
		pDoc->m_RecordSet.MoveLast(); 
		pDoc->UpdateAllViews(NULL,HINT_DB_OPENED); 
	}	 
} 
 
BOOL CFaultView::PreCreateWindow(CREATESTRUCT& cs)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	cs.style |= LVS_REPORT     | 
			 LVS_SINGLESEL     | 
			 LVS_SHOWSELALWAYS | 
			 LVS_ICON          ; 
	return CListView::PreCreateWindow(cs); 
} 
 
void CFaultView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
/* 
	case HINT_NEW_RECORD: 
		TRACE("HINT_NEW_RECORD\n"); 
 
		pRS->Open(dbOpenDynaset,pRS->GetDefaultSQL(),0); 
		pRS->MoveLast(); 
		int ItemIndex = lc.InsertItem(LVIF_TEXT | LVIF_PARAM,0, pRS->m_Name, 0, 0, 0, 0); 
		int SubitemIndex = 1; 
		strTime.Format("%d年%d月%d日(%d:%d:%d)",(pRS->m_Time).GetYear(), 
			(pRS->m_Time).GetMonth(),(pRS->m_Time).GetDay(), 
			(pRS->m_Time).GetHour(),(pRS->m_Time).GetMinute(), 
			(pRS->m_Time).GetSecond()); 
		lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT,strTime, 0, 0, 0, 0); 
		lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT, pRS->m_Notes, 0, 0, 0, 0); 
		m_nItemIndex++; 
		break; 
	} 
		 
	delete pRS; 
	*/ 
	CString		strTime; 
	CListCtrl      &lc= GetListCtrl(); 
	CMonitorDoc	*pDoc = (CMonitorDoc*) GetDocument(); 
	 
	COleVariant VariantSet; 
	COleDateTime dataTime; 
	CString str; 
	 
	switch(lHint) 
	{ 
	case HINT_DB_OPENED: 
		TRACE("HINT_DB_OPENED\n");		 
		lc.DeleteAllItems(); 
		 
		if (pDoc->m_RecordSet.GetRecordCount()==0) { 
			return; 
		} 
		pDoc->m_RecordSet.MoveLast(); 
		 
		int displayNum; 
		if ( pDoc->m_RecordSet.GetRecordCount()<=1 ) {  //数据库中只有一个固定的故障记录,则返回 
			return; 
		} 
		displayNum=pDoc->m_RecordSet.GetRecordCount()-1; //故障数据库中,总保留一个记录,防止删除错误! 
//		while (!pDoc->m_RecordSet.IsBOF())  //原先版本,数据库中没有保留一个数据记录! 
		int i; 
		for(i=0;im_RecordSet.GetFieldValue(1); 
			str.Format("%s",VariantSet.bstrVal); 
			int ItemIndex=lc.InsertItem(LVIF_TEXT|LVIF_PARAM,m_nItemIndex,str,0,0,0,0); 
			int SubitemIndex = 1; 
			VariantSet=pDoc->m_RecordSet.GetFieldValue(2); 
			dataTime=VariantSet.date; 
			strTime.Format("%d年%d月%d日(%d:%d:%d)",dataTime.GetYear(),dataTime.GetMonth(), 
				dataTime.GetDay(),dataTime.GetHour(),dataTime.GetMinute(),dataTime.GetSecond()); 
			lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT,strTime, 0, 0, 0, 0); 
			 
			VariantSet=pDoc->m_RecordSet.GetFieldValue(3); 
			str.Format("%s",VariantSet.bstrVal); 
			lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT, str, 0, 0, 0, 0); 
			pDoc->m_RecordSet.MovePrev(); 
			m_nItemIndex++; 
		} 
		break; 
	case HINT_NEW_RECORD: 
	/*	TRACE("HINT_NEW_RECORD\n"); 
	 
	  pRS->Open(dbOpenDynaset,pRS->GetDefaultSQL(),0); 
	  pRS->MoveLast(); 
	  int ItemIndex = lc.InsertItem(LVIF_TEXT | LVIF_PARAM,0, pRS->m_Name, 0, 0, 0, 0); 
	  int SubitemIndex = 1; 
	  strTime.Format("%d年%d月%d日(%d:%d:%d)",(pRS->m_Time).GetYear(), 
	  (pRS->m_Time).GetMonth(),(pRS->m_Time).GetDay(), 
	  (pRS->m_Time).GetHour(),(pRS->m_Time).GetMinute(), 
	  (pRS->m_Time).GetSecond()); 
	  lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT,strTime, 0, 0, 0, 0); 
	  lc.SetItem (ItemIndex, SubitemIndex++, LVIF_TEXT, pRS->m_Notes, 0, 0, 0, 0); 
	  m_nItemIndex++; 
	*/ 
		break; 
	default: 
		break; 
	} 
} 
 
void CFaultView::OnDbManage()  
{ 
/*	CDBManageDlg dlg(this); 
	if(dlg.DoModal()==IDOK) 
	{ 
		OnDBDeleteAll(dlg.m_dateTimePicker); 
	} 
*/ 
	//	HWND hwnd=::GetActiveWindow(); 
 
	CDBManageDlg DBdlg(this); 
	int flag=DBdlg.DoModal(); 
	// TODO: Add your command handler code here 
	CMonitorDoc *pDoc=(CMonitorDoc *)GetDocument(); 
	if(flag==IDOK) 
	{ 
		if (!(pDoc->m_RecordSet.IsOpen())) { 
			AfxMessageBox("请先打开数据库"); 
			return; 
		} 
		if (pDoc->m_RecordSet.GetRecordCount()!=0) { 
			pDoc->m_RecordSet.MoveLast(); 
		} 
		else 
			return; 
		if( (pDoc->m_RecordSet.GetRecordCount())>1) 
		{ 
			if (DBdlg.m_bDataCheck) //删除制定日期前的纪录 
			{ 
				COleVariant VariantSet; 
				COleDateTime dataTime; 
				pDoc->m_RecordSet.MoveLast(); 
				while (TRUE) { 
					VariantSet=pDoc->m_RecordSet.GetFieldValue(2); 
					dataTime=VariantSet.date; 
					if(dataTimem_RecordSet.Delete(); 
					} 
					pDoc->m_RecordSet.MovePrev(); 
					if (pDoc->m_RecordSet.GetRecordCount()<=1) { 
						break; 
					} 
				} 
			} 
			else if(DBdlg.m_bNumCheck)//删除指定个数的纪录 
			{ 
				pDoc->m_RecordSet.MoveFirst(); 
				pDoc->m_RecordSet.Move(1); 
				UINT i=DBdlg.m_nDeleteNum; 
				if (i<=0) { 
					return; 
				} 
				while ((!(pDoc->m_RecordSet.IsEOF()))&&(i!=0)) 
				{ 
					pDoc->m_RecordSet.Delete(); 
					pDoc->m_RecordSet.MoveNext(); 
					i--; 
					if (pDoc->m_RecordSet.IsEOF()) { 
						break; 
					} 
				} 
			} 
			 
			pDoc->UpdateAllViews(NULL,HINT_DB_OPENED);			 
		} 
 
		/*  //旧版本,没有固定数据记录! 
		if((pDoc->m_RecordSet.GetRecordCount())!=0) 
		{ 
			if (DBdlg.m_bDataCheck) //删除制定日期前的纪录 
			{ 
				COleVariant VariantSet; 
				COleDateTime dataTime; 
				pDoc->m_RecordSet.MoveFirst(); 
				while (!(pDoc->m_RecordSet.IsEOF())) 
				{ 
					VariantSet=pDoc->m_RecordSet.GetFieldValue(2); 
					dataTime=VariantSet.date; 
					if(dataTimem_RecordSet.Delete(); 
					} 
					pDoc->m_RecordSet.MoveNext(); 
				} 
			} 
			else if(DBdlg.m_bNumCheck)//删除指定个数的纪录 
			{ 
				pDoc->m_RecordSet.MoveFirst(); 
				UINT i=DBdlg.m_nDeleteNum; 
				while ((!(pDoc->m_RecordSet.IsEOF()))&&(i!=0)) 
				{ 
					pDoc->m_RecordSet.Delete(); 
					pDoc->m_RecordSet.MoveNext(); 
					i--; 
				} 
			} 
			pDoc->UpdateAllViews(NULL,HINT_DB_OPENED);			 
		} 
		*/ 
	}//IDOK  END 
//	m_preKeyStatus=-1; 
//	m_bDlgClock=FALSE; 
	//	::EnableWindow(hwnd,TRUE); 
	//	::SetFocus(hwnd); 
} 
 
void CFaultView::OnDBDeleteAll(COleDateTime time) 
{ 
	TRACE("------------OnDBDeleteAll---------------\n"); 
/*	CMonitorDoc	*pDoc = (CMonitorDoc*) GetDocument(); 
    CDaoRecordsetAccess *pRS ; 
	pRS = new CDaoRecordsetAccess(pDoc->m_pDB); 
	try 
	{ 
		pRS->Open(dbOpenDynaset,pRS->GetDefaultSQL(),0); 
	} 
	catch(CDaoException* e) 
	{ 
		AfxMessageBox(e->m_pErrorInfo->m_strDescription); 
		e->Delete(); 
	} 
	if(pRS) 
	{ 
		if(pRS->GetRecordCount()!=0) 
		{ 
			pRS->MoveFirst(); 
			while (!pRS->IsEOF()) 
			{ 
				if(pRS->m_TimeDelete(); 
				} 
				pRS->MoveNext(); 
			} 
			pDoc->m_RecordCount=pRS->GetRecordCount(); 
		} 
	} 
	delete pRS; 
	pDoc->UpdateAllViews(NULL, HINT_DB_OPENED, NULL); 
	*/ 
} 
 
BOOL CFaultView::OnPreparePrinting(CPrintInfo* pInfo)  
{ 
	/* 
	// TODO: call DoPreparePrinting to invoke the Print dialog box 
	CMonitorDoc* pDoc=(CMonitorDoc*)GetDocument(); 
	//if(pDoc->m_RecordCount > 100) 
	if(m_nRecordCount> 100) 
		pInfo->SetMaxPage(100/nLinesPerPage+1); 
//	else pInfo->SetMaxPage(pDoc->m_RecordCount/nLinesPerPage+1); 
	else pInfo->SetMaxPage(m_nRecordCount/30+1); 
	 
	return DoPreparePrinting(pInfo); 
	*/ 
	if(m_nRecordCount> 100) 
		pInfo->SetMaxPage(100/nLinesPerPage+1); 
	else pInfo->SetMaxPage(m_nRecordCount/nLinesPerPage+1); 
	return DoPreparePrinting(pInfo); 
} 
 
void CFaultView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
} 
 
void CFaultView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
} 
 
void CFaultView::OnPrint(CDC* pDC, CPrintInfo* pInfo)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
 
	int nStart,nEnd; 
	CFont fontRecords; 
	CRect rectNum,rectFault,rectTime,rectNote; 
	pDC->SetMapMode(MM_TWIPS); 
	CMonitorDoc* pDoc=(CMonitorDoc*)GetDocument(); 
///////////////////////////////////////// 
	if (pDoc->m_RecordSet.GetRecordCount()!=0) { 
		pDoc->m_RecordSet.MoveLast(); 
	} 
	if (pDoc->m_RecordSet.GetRecordCount()<=1) { 
		return; 
	} 
/////////////////////////////////////////////// 
	m_nPage=pInfo->m_nCurPage; 
	if (m_nPage==0) { 
		nStart=0; 
	} 
	else 
		nStart=(m_nPage-1)*nLinesPerPage; 
	nEnd=nStart+nLinesPerPage; 
 
	m_rectPrint=pInfo->m_rectDraw; 
	pDC->DPtoLP(m_rectPrint); 
	 
	m_rectTitle.left=m_rectPrint.left; 
	m_rectTitle.right=m_rectPrint.right; 
	m_rectTitle.top=m_rectPrint.top; 
	m_rectTitle.bottom=m_rectPrint.top+m_rectPrint.Height()/20; 
 
	m_rectHeader.left=m_rectPrint.left; 
	m_rectHeader.right=m_rectPrint.right; 
	m_rectHeader.top=m_rectTitle.bottom; 
	m_rectHeader.bottom=m_rectTitle.bottom+m_rectPrint.Height()/30; 
 
	m_rectFooter.left=m_rectPrint.left; 
	m_rectFooter.right=m_rectPrint.right; 
	m_rectFooter.top=m_rectPrint.bottom-m_rectPrint.Height()/30; 
	m_rectFooter.bottom=m_rectPrint.bottom; 
 
	m_rectRecords.left=m_rectPrint.left; 
	m_rectRecords.right=m_rectPrint.right; 
	m_rectRecords.top=m_rectHeader.bottom; 
	m_rectRecords.bottom=m_rectFooter.top; 
 
	int fontHigh=-240; 
	fontRecords.CreateFont(fontHigh,0,0,0,400,FALSE,FALSE, 
		0,ANSI_CHARSET,OUT_DEFAULT_PRECIS, 
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 
		DEFAULT_PITCH|FF_MODERN,"宋体"); 
	CFont* pOldFont=(CFont*)pDC->SelectObject(&fontRecords); 
	int nMode=pDC->SetBkMode(TRANSPARENT); 
	pDC->Rectangle(m_rectPrint); 
	pDC->Rectangle(m_rectTitle); 
	pDC->Rectangle(m_rectHeader); 
	pDC->Rectangle(m_rectFooter); 
	pDC->Rectangle(m_rectRecords); 
 
	PrintPageHeader(pDC); 
	 
	int recordCount=pDoc->m_RecordCount;  //pDoc->m_RecordSet.GetRecordCount(); 
	if (pDoc->m_RecordSet.GetRecordCount()!=0) { 
		pDoc->m_RecordSet.MoveLast(); 
	} 
	for(int k=0;km_RecordSet.IsBOF()) { 
			break; 
		} 
		pDoc->m_RecordSet.MovePrev(); 
	} 
 
	CString str; 
	CString strNum,strTime; 
	COleVariant VariantSet; 
	COleDateTime dataTime; 
 
	double nwidth=m_rectPrint.Width(); 
	int str_y=m_rectRecords.top-80; 
	int strNUM_x=(int)(m_rectPrint.left+300); 
	int strTYPE_x=(int)(m_rectPrint.left+nwidth*NUMper+300); 
	int strTIME_x=(int)(m_rectPrint.left+nwidth*(NUMper+TYPEper)+300); 
	int strNOTE_x=(int)(m_rectPrint.left+nwidth*(NUMper+TYPEper+TIMEper)+300); 
	int nHeight=(int)(m_rectPrint.Height()*52.0/60.0/32.0); 
	pDC->MoveTo((int)(m_rectRecords.left+nwidth*NUMper),m_rectHeader.top); 
	pDC->LineTo((int)(m_rectRecords.left+nwidth*NUMper),m_rectRecords.bottom); 
	pDC->MoveTo((int)(m_rectRecords.left+nwidth*(NUMper+TYPEper)),m_rectHeader.top); 
	pDC->LineTo((int)(m_rectRecords.left+nwidth*(NUMper+TYPEper)),m_rectRecords.bottom); 
	pDC->MoveTo((int)(m_rectRecords.left+nwidth*(NUMper+TYPEper+TIMEper)),m_rectHeader.top); 
	pDC->LineTo((int)(m_rectRecords.left+nwidth*(NUMper+TYPEper+TIMEper)),m_rectRecords.bottom); 
	 
	for(int i=0;im_RecordSet.IsBOF()) { 
			break; 
		} 
		strNum.Format("%d",i+1+nStart); //0 
		pDC->TextOut(strNUM_x,str_y+i*nHeight,strNum) ; 
		pDC->MoveTo(m_rectPrint.left,str_y+i*nHeight+(nHeight-fontHigh)/2+fontHigh); 
		pDC->LineTo(m_rectPrint.right,str_y+i*nHeight+(nHeight-fontHigh)/2+fontHigh); 
		 
		VariantSet=pDoc->m_RecordSet.GetFieldValue(1);  //1 
		str.Format("%s",VariantSet.bstrVal); 
		pDC->TextOut(strTYPE_x,str_y+i*nHeight,str) ; 
		 
		 
		VariantSet=pDoc->m_RecordSet.GetFieldValue(2);  //2 
		dataTime=VariantSet.date; 
		strTime.Format("%d年%d月%d日(%d:%d:%d)",dataTime.GetYear(),dataTime.GetMonth(), 
			dataTime.GetDay(),dataTime.GetHour(),dataTime.GetMinute(),dataTime.GetSecond());	 
		pDC->TextOut(strTIME_x,str_y+i*nHeight,strTime) ; 
		 
		VariantSet=pDoc->m_RecordSet.GetFieldValue(3); 
		str.Format("%s",VariantSet.bstrVal); 
		pDC->TextOut(strNOTE_x,str_y+i*nHeight,str) ; 
 
	//	pSet->MoveNext(); 
		pDoc->m_RecordSet.MovePrev(); 
 
		/////////////////////////////////////////// 
		if (pDoc->m_RecordSet.IsBOF()) { 
			break; 
		} 
		pDoc->m_RecordSet.MovePrev(); //用于测试是否到了固定记录! 
		if (pDoc->m_RecordSet.IsBOF()) { 
			break; 
		} 
		pDoc->m_RecordSet.MoveNext() ; //若没到!再移动回去! 
		//////////////////////////////////// 
		if (pDoc->m_RecordSet.IsBOF()) { 
			break; 
		} 
	} 
	PrintPageFooter(pDC); 
	pDC->SelectObject(pOldFont); 
	pDC->SetBkMode(nMode); 
	pDC->SetMapMode(MM_TEXT); 
} 
 
void CFaultView::PrintPageHeader(CDC *pDC) 
{ 
	CRect rectNum,rectFault,rectTime,rectNote; 
	CFont fontTitle,fontHeader; 
	fontTitle.CreateFont(-360,0,0,0,400,FALSE,FALSE, 
		0,ANSI_CHARSET,OUT_DEFAULT_PRECIS, 
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 
		DEFAULT_PITCH|FF_MODERN,"楷体_GB2312"); 
	fontHeader.CreateFont(-280,0,0,0,400,FALSE,FALSE, 
		0,ANSI_CHARSET,OUT_DEFAULT_PRECIS, 
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 
		DEFAULT_PITCH|FF_MODERN,"黑体"); 
	 
	CFont* pOldFont=(CFont*)pDC->SelectObject(&fontTitle); 
	 
	 
	pDC->DrawText("故障记录报表",m_rectTitle,DT_CENTER|DT_VCENTER|DT_SINGLELINE) ; 
	pDC->SelectObject(&fontHeader); 
	rectNum=m_rectHeader; 
	rectNum.left=m_rectHeader.left; 
	rectNum.right=(int)(m_rectHeader.left+m_rectHeader.Width()*NUMper); 
	rectFault=m_rectHeader; 
	rectFault.left=rectNum.right; 
	rectFault.right=(int)(rectFault.left+m_rectHeader.Width()*TYPEper); 
	rectTime=m_rectHeader; 
	rectTime.left=rectFault.right; 
	rectTime.right=(int)(rectTime.left+m_rectHeader.Width()*TIMEper); 
	rectNote=m_rectHeader; 
	rectNote.left=rectTime.right; 
	//rectNote.right=rectNote.left+m_rectHeader.Width()/2; 
	 
	pDC->DrawText("序号",rectNum,DT_CENTER|DT_VCENTER|DT_SINGLELINE) ; 
	pDC->DrawText("故障类型",rectFault,DT_CENTER|DT_VCENTER|DT_SINGLELINE) ; 
	pDC->DrawText("故障发生时间",rectTime,DT_CENTER|DT_VCENTER|DT_SINGLELINE) ; 
	pDC->DrawText("故障描述",rectNote,DT_CENTER|DT_VCENTER|DT_SINGLELINE) ; 
	 
	pDC->SelectObject(pOldFont); 
} 
 
void CFaultView::PrintPageFooter(CDC *pDC) 
{ 
	CFont fontFooter; 
	CRect rectTemp; 
	CString str; 
	fontFooter.CreateFont(-280,0,0,0,400,FALSE,FALSE, 
		0,ANSI_CHARSET,OUT_DEFAULT_PRECIS, 
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 
		DEFAULT_PITCH|FF_MODERN,"宋体"); 
	CFont* pOldFont=(CFont*)pDC->SelectObject(&fontFooter); 
 
	str.Format("第 %d 页",m_nPage); 
	rectTemp=m_rectFooter; 
	rectTemp.right=m_rectFooter.right-100; 
	pDC->DrawText(str,rectTemp,DT_RIGHT|DT_VCENTER|DT_SINGLELINE) ; 
	pDC->SelectObject(pOldFont); 
 
}