登录 注册
当前位置:主页 > 资源下载 > 9 > ListView应用实例

ListView应用实例

  • 更新:2024-07-05 23:36:56
  • 大小:60KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:硬件开发 - 开发技术
  • 格式:RAR

资源介绍

// 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(); }