ListView 应用示例

时间:2013-04-08 12:11:25
【文件属性】:

文件名称:ListView 应用示例

文件大小:60KB

文件格式:RAR

更新时间:2013-04-08 12:11:25

ListView

// CXListView 消息处理程序 void CXListView::AddItem() { CListCtrl &ListCtrl = GetListCtrl(); if (++m_nAlarmCount > 10) { ListCtrl.DeleteAllItems(); m_nAlarmCount = 1; } //添加告警序数 CString strIndex; strIndex.Format(_T("%02d"), m_nAlarmCount); LV_ITEM lvi; lvi.mask = LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 0; lvi.pszText = (LPWSTR)(LPCTSTR)strIndex; //lvi.iImage = 0; //lvi.stateMask = LVIS_STATEIMAGEMASK; //lvi.state = INDEXTOSTATEIMAGEMASK(1); ListCtrl.InsertItem(&lvi); //添加告警时间 //CTime; SYSTEMTIME sysTime; GetLocalTime(&sysTime); CString strTime; strTime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d"), sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond); ListCtrl.SetItemText(0, 1, strTime); return; } void CXListView::OnInitialUpdate() { CListView::OnInitialUpdate(); // TODO: 在此添加专用代码和/或调用基类 CListCtrl &theCtrl = GetListCtrl(); theCtrl.ModifyStyle (0,LVS_SINGLESEL|LVS_REPORT); //theCtrl.ModifyStyle (LVS_EDITLABELS,0);//禁止修改列标题 theCtrl.SetExtendedStyle (LVS_EX_FULLROWSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_INFOTIP|LVS_EX_SUBITEMIMAGES|LVS_EX_GRIDLINES); theCtrl.InsertColumn(0, _T("序号"), LVCFMT_LEFT, 50); theCtrl.InsertColumn(1, _T("告警发生时间"), LVCFMT_CENTER, 150); } void CXListView::OnAdditem() { // TODO: 在此添加命令处理程序代码 AddItem(); }


【文件预览】:
ListView
----resource.h(588B)
----XListView.h(652B)
----stdafx.h(2KB)
----MainFrm.h(888B)
----ChildView.cpp(878B)
----ListView.aps(61KB)
----ChildView.h(408B)
----stdafx.cpp(139B)
----XListView.cpp(2KB)
----ListView.rc(9KB)
----ReadMe.txt(3KB)
----MainFrm.cpp(2KB)
----ListView.h(491B)
----ListView.cpp(2KB)
----res()
--------ListView.rc2(364B)
--------ListView.ico(21KB)
--------Toolbar.bmp(598B)
----ListView.vcproj(6KB)
ListView.sln
ListView.suo

网友评论

  • 详细的list用法,很有学习价值。感谢分享。