www.pudn.com > duanxinfangwei.rar > FormView_RuntimeQuery.cpp


// FormView_RuntimeQuery.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "smspreventforgery.h" 
#include "FormView_RuntimeQuery.h" 
#include "DbInterface.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_RuntimeQuery 
 
IMPLEMENT_DYNCREATE(CFormView_RuntimeQuery, CListView) 
 
CFormView_RuntimeQuery::CFormView_RuntimeQuery() 
{ 
} 
 
CFormView_RuntimeQuery::~CFormView_RuntimeQuery() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CFormView_RuntimeQuery, CListView) 
	//{{AFX_MSG_MAP(CFormView_RuntimeQuery) 
	ON_WM_TIMER() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_RuntimeQuery drawing 
 
void CFormView_RuntimeQuery::OnDraw(CDC* pDC) 
{ 
	CDocument* pDoc = GetDocument(); 
	// TODO: add draw code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_RuntimeQuery diagnostics 
 
#ifdef _DEBUG 
void CFormView_RuntimeQuery::AssertValid() const 
{ 
	CListView::AssertValid(); 
} 
 
void CFormView_RuntimeQuery::Dump(CDumpContext& dc) const 
{ 
	CListView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CFormView_RuntimeQuery message handlers 
 
void CFormView_RuntimeQuery::OnInitialUpdate()  
{ 
	CListView::OnInitialUpdate(); 
	 
	/* 改变列表风格 */ 
	CListCtrl &listctrl = GetListCtrl(); 
 
	listctrl.ModifyStyle(0, LVS_REPORT); 
	listctrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
 
	/* 设定表头 */ 
	listctrl.InsertColumn(1, "查询者", LVCFMT_LEFT, 80); 
	listctrl.InsertColumn(2, "短信内容", LVCFMT_LEFT, 150); 
	listctrl.InsertColumn(3, "查询时间", LVCFMT_LEFT, 150);	 
 
	/* 设定定时器 */ 
	SetTimer(UPDATEQUERYINFO, 5000, 0);  
} 
 
/********************************************************************** 
 * 函数名:	DspRuntimeQueryInfo 
 * 功  能:  追加显示查询信息 
 * 参  数:  void 
 * 返回值:  void							 
 *********************************************************************/ 
void CFormView_RuntimeQuery::DspRuntimeQueryInfo() 
{ 
	/* 取得未显示的查询信息列表 */ 
	CDbInterface db; 
	std::list queryRecList; 
	db.GetQueryRecList(queryRecList, UNDSP); 
 
	/* 显示 */ 
	CListCtrl &listctrl = GetListCtrl(); 
 
	while(queryRecList.size() > 0) 
	{ 
		QUERYREC queryRec; 
		queryRec = queryRecList.front(); 
		queryRecList.pop_front(); 
 
		listctrl.InsertItem(LVIF_TEXT | LVIF_STATE, 0, 0, 0, 0, 0, 0); 
		listctrl.SetItemText(0, 0, queryRec.queryer); 
		listctrl.SetItemText(0, 1, queryRec.queryinfo); 
		listctrl.SetItemText(0, 2, queryRec.querytime); 
	} 
} 
 
/********************************************************************** 
 * 函数名:	OnTimer 
 * 功  能:  定时消息处理 
 * 参  数:  void 
 * 返回值:  void							 
 *********************************************************************/ 
void CFormView_RuntimeQuery::OnTimer(UINT nIDEvent)  
{ 
	switch(nIDEvent) 
	{ 
	case UPDATEQUERYINFO: 
		DspRuntimeQueryInfo(); 
		break; 
	} 
//	CListView::OnTimer(nIDEvent); 
}