中间件标准版5.1git,去除基础模块

XListCtrl.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // MyListCtrl.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "XListCtrl.h"
  5. // CMyListCtrl
  6. IMPLEMENT_DYNAMIC(CXListCtrl, CMFCListCtrl)
  7. CXListCtrl::CXListCtrl()
  8. {
  9. }
  10. CXListCtrl::~CXListCtrl()
  11. {
  12. }
  13. BEGIN_MESSAGE_MAP(CXListCtrl, CMFCListCtrl)
  14. END_MESSAGE_MAP()
  15. /*****************************************************************
  16. **【函数名称】 PreSubclassWindow
  17. **【函数功能】 修正列表控件的相关扩展属性
  18. **【参数】
  19. **【返回值】
  20. ****************************************************************/
  21. void CXListCtrl::PreSubclassWindow()
  22. {
  23. SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
  24. EnableMarkSortedColumn();
  25. CMFCListCtrl::PreSubclassWindow();
  26. }
  27. /*****************************************************************
  28. **【函数名称】 GetIndexByContent
  29. **【函数功能】 根据指定列的内容获取所在行的索引值
  30. **【参数】 nColumn 要查找内容所在的列
  31. lpszContent 要查找的内容
  32. **【返回值】 -1 未找到
  33. 当前内容所在行的索引
  34. ****************************************************************/
  35. int CXListCtrl::GetIndexByContent(const UINT nColumn, LPCTSTR lpszContent)
  36. {
  37. for( int i=0; i < GetItemCount(); i++ )
  38. {
  39. CString strTmp = GetItemText(i, nColumn);
  40. if(strTmp == lpszContent) return i;
  41. } // end for
  42. return -1;
  43. }
  44. /*****************************************************************
  45. **【函数名称】 RemoveSelection
  46. **【函数功能】 删除选中行
  47. **【参数】
  48. **【返回值】
  49. ****************************************************************/
  50. void CXListCtrl::RemoveSelection()
  51. {
  52. POSITION pos = this->GetFirstSelectedItemPosition();
  53. while(pos != NULL)
  54. {
  55. int iIndex = this->GetNextSelectedItem(pos);
  56. this->DeleteItem(iIndex);
  57. pos = this->GetFirstSelectedItemPosition();
  58. } // end while
  59. }