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.

134 lines
3.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: simprop3.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // SimProp3.cpp : implementation file
  11. //
  12. #include "stdafx.h"
  13. #include "common.h"
  14. #ifdef _DEBUG
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. ///////////////////////////////////////
  21. const TColumnHeaderItem rgzColumnHeader[] =
  22. {
  23. { IDS_SIM_KERBEROS_PRINCIPAL_NAME, 85 },
  24. { 0, 0 },
  25. };
  26. /////////////////////////////////////////////////////////////////////////////
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CSimOtherPropPage property page
  29. CSimOtherPropPage::CSimOtherPropPage() : CSimPropPage(CSimOtherPropPage::IDD)
  30. {
  31. //{{AFX_DATA_INIT(CSimOtherPropPage)
  32. // NOTE: the ClassWizard will add member initialization here
  33. //}}AFX_DATA_INIT
  34. m_prgzColumnHeader = rgzColumnHeader;
  35. }
  36. void CSimOtherPropPage::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CSimPropPage::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CSimOtherPropPage)
  40. // NOTE: the ClassWizard will add DDX and DDV calls here
  41. //}}AFX_DATA_MAP
  42. if (!pDX->m_bSaveAndValidate)
  43. {
  44. // Fill in the listview
  45. ListView_DeleteAllItems(m_hwndListview);
  46. for (CSimEntry * pSimEntry = m_pData->m_pSimEntryList;
  47. pSimEntry != NULL;
  48. pSimEntry = pSimEntry->m_pNext)
  49. {
  50. if (pSimEntry->m_eDialogTarget != eOther)
  51. continue;
  52. ListView_AddString(m_hwndListview, pSimEntry->PchGetString(), (LPARAM)pSimEntry);
  53. } // for
  54. ListView_SelectItem(m_hwndListview, 0);
  55. } // if
  56. }
  57. BEGIN_MESSAGE_MAP(CSimOtherPropPage, CSimPropPage)
  58. //{{AFX_MSG_MAP(CSimOtherPropPage)
  59. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  60. ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. void CSimOtherPropPage::OnButtonAdd()
  64. {
  65. CSimAddKerberosDlg dlg;
  66. if (dlg.DoModal() != IDOK)
  67. return;
  68. CString str = dlg.m_strName;
  69. int iItem = ListView_FindString(m_hwndListview, str);
  70. if (iItem >= 0)
  71. {
  72. ListView_SelectItem(m_hwndListview, iItem);
  73. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  74. MB_OK | MB_ICONINFORMATION, NULL, 0);
  75. return;
  76. }
  77. CSimEntry * pSimEntry = m_pData->PAddSimEntry(str);
  78. iItem = ListView_AddString(m_hwndListview, str, (LPARAM)pSimEntry);
  79. ListView_SelectItem(m_hwndListview, iItem);
  80. SetDirty();
  81. } // OnButtonAdd()
  82. void CSimOtherPropPage::OnButtonEdit()
  83. {
  84. int iItem;
  85. CSimEntry * pSimEntry = (CSimEntry *)ListView_GetItemLParam(m_hwndListview, -1, OUT &iItem);
  86. if (pSimEntry == NULL || iItem < 0)
  87. {
  88. // No item selected
  89. return;
  90. }
  91. CString str;
  92. ListView_GetItemString(m_hwndListview, iItem, 0, OUT str);
  93. ASSERT(!str.IsEmpty());
  94. CSimAddKerberosDlg dlg;
  95. dlg.m_strName = str;
  96. if (dlg.DoModal() != IDOK)
  97. return;
  98. if (str == dlg.m_strName)
  99. {
  100. // Strings are identical
  101. return;
  102. }
  103. int iItemT = ListView_FindString(m_hwndListview, dlg.m_strName);
  104. if (iItemT >= 0)
  105. {
  106. ListView_SelectItem(m_hwndListview, iItemT);
  107. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  108. MB_OK | MB_ICONINFORMATION, NULL, 0);
  109. return;
  110. }
  111. CString strTemp = dlg.m_strName;
  112. pSimEntry->SetString(strTemp);
  113. UpdateData(FALSE);
  114. iItem = ListView_FindString(m_hwndListview, strTemp);
  115. ListView_SelectItem(m_hwndListview, iItem);
  116. SetDirty();
  117. } // OnButtonEdit()
  118. #endif // _DEBUG