📄 formitemtable.cpp
字号:
// FormItemTable.cpp: implementation of the CFormItemTable class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FormListCtrl.h"
#include "FormItemTable.h"
#include "SmartAccessor.h"
#include "RowsetIndex.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFormItemTable::CFormItemTable()
: m_pSession (NULL)
{
}
CFormItemTable::~CFormItemTable()
{
}
void CFormItemTable::UpdateData()
{
LoadList();
}
// CFormItemTable::LoadList
//
// Loads the list by appending to any existing items
//
void CFormItemTable::LoadList(BOOL bClear)
{
CIndexTable<CSmartAccessor, CRowsetIndex<CRowset> >
table;
HRESULT hr = E_FAIL;
CDBPropSet propSetTbl(DBPROPSET_ROWSET);
LPCTSTR pszIndex = NULL;
if(bClear)
ClearList();
if(!m_strIndex.IsEmpty())
pszIndex = m_strIndex;
//
// Use a base table cursor
//
propSetTbl.AddProperty(DBPROP_BOOKMARKS, true);
propSetTbl.AddProperty(DBPROP_OWNUPDATEDELETE, true);
propSetTbl.AddProperty(DBPROP_OWNINSERT, true);
propSetTbl.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
propSetTbl.AddProperty(DBPROP_OTHERINSERT, true);
propSetTbl.AddProperty(DBPROP_CANFETCHBACKWARDS, true);
propSetTbl.AddProperty(DBPROP_QUICKRESTART, true);
//
// Open the table
//
hr = table.Open(*m_pSession, m_strTable, pszIndex, &propSetTbl);
if(SUCCEEDED(hr))
{
ULONG iKey,
iVal;
int nKey,
iIndex;
CString strVal;
table.GetInternalColumnNo((TCHAR*)(LPCTSTR)m_strKeyCol, &iKey);
table.GetInternalColumnNo((TCHAR*)(LPCTSTR)m_strValCol, &iVal);
//
// Scan the whole table
//
for(hr = table.MoveFirst(); hr == S_OK; hr = table.MoveNext())
if(table.Get(iKey, nKey) && table.Get(iVal, strVal))
iIndex = AddString(strVal, (DWORD)nKey);
}
}
// CFormItemTable::Init
//
// Initialize the combo box
//
void CFormItemTable::Init(LPCTSTR pszCaption,
CSession* pSession,
LPCTSTR pszTable,
LPCTSTR pszIndex,
LPCTSTR pszKeyCol,
LPCTSTR pszValCol,
DWORD dwFlags)
{
CFormItem::Init(pszCaption, dwFlags);
ASSERT(pSession);
ASSERT(pszTable);
ASSERT(pszKeyCol);
//
// Store the initialization values for later
//
m_pSession = pSession;
m_strTable = pszTable;
m_strIndex = pszIndex;
m_strKeyCol = pszKeyCol;
m_strValCol = pszValCol;
LoadList(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -