Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997-1999 **/
  4. /**********************************************************************/
  5. /*
  6. snmpclst.cpp
  7. snmp community list control
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "snmpsnap.h"
  12. #include "snmpclst.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. int CCommList::InsertString( int nIndex, LPCTSTR lpszItem )
  19. {
  20. if (nIndex != -1)
  21. return CListCtrl::InsertItem(nIndex, lpszItem);
  22. else
  23. return CListCtrl::InsertItem(CListCtrl::GetItemCount(), lpszItem);
  24. }
  25. int CCommList::SetCurSel( int nSelect )
  26. {
  27. return CListCtrl::SetItemState(nSelect, LVIS_SELECTED, LVIS_SELECTED);
  28. }
  29. int CCommList::GetCurSel( ) const
  30. {
  31. for (int i=0, count=CListCtrl::GetItemCount(); i < count; i++)
  32. {
  33. if (CListCtrl::GetItemState(i, LVIS_SELECTED) & LVIS_SELECTED)
  34. return i;
  35. }
  36. return LB_ERR;
  37. }
  38. void CCommList::GetText( int nIndex, CString& rString ) const
  39. {
  40. rString = CListCtrl::GetItemText(nIndex, 0);
  41. }
  42. int CCommList::DeleteString( UINT nIndex )
  43. {
  44. return CListCtrl::DeleteItem(nIndex);
  45. }
  46. int CCommList::GetCount( ) const
  47. {
  48. return CListCtrl::GetItemCount();
  49. }
  50. void CCommList::OnInitList()
  51. {
  52. LV_COLUMN columnSettings;
  53. RECT winRect;
  54. CString caption;
  55. GetClientRect(&winRect);
  56. if (!caption.LoadString(IDS_SEC_COMMUNITY))
  57. caption = "????";
  58. columnSettings.mask = LVCF_TEXT | LVCF_WIDTH;
  59. columnSettings.cx = 4 * winRect.right / 7;
  60. columnSettings.pszText = caption.GetBuffer(caption.GetLength()+1);
  61. CListCtrl::InsertColumn(0, &columnSettings);
  62. if (!caption.LoadString(IDS_SEC_PERMISSIONS))
  63. caption = "????";
  64. columnSettings.cx = 2 * winRect.right / 7;
  65. columnSettings.pszText = caption.GetBuffer(caption.GetLength()+1);
  66. CListCtrl::InsertColumn(1, &columnSettings);
  67. ListView_SetExtendedListViewStyle(m_hWnd, LVS_EX_FULLROWSELECT);
  68. }