16,465
社区成员
发帖
与我相关
我的任务
分享
int CLeftView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CRect rectClient;
GetClientRect(&rectClient);
GetListCtrl().ModifyStyle(0,LVS_REPORT|LVS_SHOWSELALWAYS);
GetListCtrl().SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES);
GetListCtrl().InsertColumn(0,"主模块第一列",LVCFMT_CENTER,100);
try
{
CDatabase db;
if( db.Open("freehis"))
{
db.ExecuteSQL( "set names 'gbk'");
CMainModuleRecordSet *pMainModuleRecordSet = new CMainModuleRecordSet(&db);
pMainModuleRecordSet->Open(CRecordset::snapshot , "select * from T_MainModule");
LVITEM lvi;
CString strItem;
int i = 0;
while( ! pMainModuleRecordSet->IsEOF())
{
strItem.Format("%d-%s" , pMainModuleRecordSet->m_id, pMainModuleRecordSet->m_MainModuleName);
lvi.mask = LVIF_TEXT;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
lvi.iImage = 0; //
GetListCtrl().InsertItem(&lvi);
//GetListCtrl().InsertItem(LVIF_TEXT | LVIF_PARAM, i, _T("m"), 0, 0, 0, 0);
//GetListCtrl().InsertItem(i,strItem,0);
//GetListCtrl().SetItemText(i,1,strItem);
i++;
strItem = "";
pMainModuleRecordSet->MoveNext();
}
db.Close();
if (pMainModuleRecordSet!=NULL)
{
delete pMainModuleRecordSet;
}
}
}
catch (CDBException* e)
{
AfxMessageBox( e->m_strError);
e->Delete();
}
return 0;
}