Leaked source code of windows server 2003
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.

138 lines
3.7 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. CThemeContextActivator activator;
  66. CSimAddKerberosDlg dlg;
  67. if (dlg.DoModal() != IDOK)
  68. return;
  69. CString str = dlg.m_strName;
  70. int iItem = ListView_FindString(m_hwndListview, str);
  71. if (iItem >= 0)
  72. {
  73. ListView_SelectItem(m_hwndListview, iItem);
  74. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  75. MB_OK | MB_ICONINFORMATION, NULL, 0);
  76. return;
  77. }
  78. CSimEntry * pSimEntry = m_pData->PAddSimEntry(str);
  79. iItem = ListView_AddString(m_hwndListview, str, (LPARAM)pSimEntry);
  80. ListView_SelectItem(m_hwndListview, iItem);
  81. SetDirty();
  82. } // OnButtonAdd()
  83. void CSimOtherPropPage::OnButtonEdit()
  84. {
  85. CThemeContextActivator activator;
  86. int iItem;
  87. CSimEntry * pSimEntry = (CSimEntry *)ListView_GetItemLParam(m_hwndListview, -1, OUT &iItem);
  88. if (pSimEntry == NULL || iItem < 0)
  89. {
  90. // No item selected
  91. return;
  92. }
  93. CString str;
  94. ListView_GetItemString(m_hwndListview, iItem, 0, OUT str);
  95. ASSERT(!str.IsEmpty());
  96. CSimAddKerberosDlg dlg;
  97. dlg.m_strName = str;
  98. if (dlg.DoModal() != IDOK)
  99. return;
  100. if (str == dlg.m_strName)
  101. {
  102. // Strings are identical
  103. return;
  104. }
  105. int iItemT = ListView_FindString(m_hwndListview, dlg.m_strName);
  106. if (iItemT >= 0)
  107. {
  108. ListView_SelectItem(m_hwndListview, iItemT);
  109. ReportErrorEx (GetSafeHwnd(),IDS_SIM_ERR_KERBEROS_NAME_ALREADY_EXISTS,S_OK,
  110. MB_OK | MB_ICONINFORMATION, NULL, 0);
  111. return;
  112. }
  113. CString strTemp = dlg.m_strName;
  114. pSimEntry->SetString(strTemp);
  115. UpdateData(FALSE);
  116. iItem = ListView_FindString(m_hwndListview, strTemp);
  117. ListView_SelectItem(m_hwndListview, iItem);
  118. SetDirty();
  119. } // OnButtonEdit()
  120. #endif // _DEBUG