www.gusucode.com > VC++毕业设计-库存管理系统(Access)-源码程序 > VC++毕业设计-库存管理系统(Access)-源码程序/code/源程序/BaseListBox.cpp
//Download by http://www.NewXing.com // BaseListBox.cpp : implementation file // #include "stdafx.h" #include "商品库存管理系统.h" #include "BaseListBox.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CMyApp theApp; ///////////////////////////////////////////////////////////////////////////// // CBaseListBox CBaseListBox::CBaseListBox() { } CBaseListBox::~CBaseListBox() { } BEGIN_MESSAGE_MAP(CBaseListBox, CListBox) //{{AFX_MSG_MAP(CBaseListBox) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CBaseListBox message handlers BOOL CBaseListBox::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13) pMsg->wParam=9; return CListBox::PreTranslateMessage(pMsg); } bool CBaseListBox::SetRecordset(_RecordsetPtr rRst, CString sField) { CString sText; bool returnvalue; this->rst=rRst; this->m_Field=sField; if(theApp.GetRecordCount(rst)>0) { for(int i=0;i<theApp.GetRecordCount(rst);i++) { rst->MoveFirst(); rst->Move(i); try{ sText=(char*)(_bstr_t)rst->GetCollect((_bstr_t)sField); this->AddString(sText); } catch(...) { returnvalue=false; goto err; } } returnvalue=true; } else returnvalue=false; err: return returnvalue; } void CBaseListBox::UpDating() { CString sText; this->ResetContent(); if(theApp.GetRecordCount(rst)>0) { for(int i=0;i<theApp.GetRecordCount(rst);i++) { rst->MoveFirst(); rst->Move(i); try{ sText=(char*)(_bstr_t)rst->GetCollect((_bstr_t)m_Field); this->AddString(sText); } catch(...) { return; } } } } BOOL CBaseListBox::DestroyWindow() { rst->Close(); return CListBox::DestroyWindow(); }