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.

129 lines
3.1 KiB

  1. #include "stdafx.h"
  2. #include "compdata.h"
  3. #include "wizinfo.hpp"
  4. #include "ncgen.hpp"
  5. const DWORD NewClassGeneralPage::help_map[] =
  6. {
  7. IDC_CREATE_CLASS_CN, IDH_CREATE_CLASS_CN,
  8. IDC_CREATE_CLASS_LDN, IDH_CREATE_CLASS_LDN,
  9. IDC_CREATE_CLASS_OID, IDH_CREATE_CLASS_OID,
  10. IDC_DESCRIPTION_EDIT, IDH_CLASS_GENERAL_DESCRIPTION_EDIT,
  11. IDC_CREATE_CLASS_PARENT, IDH_CREATE_CLASS_PARENT,
  12. IDC_CREATE_CLASS_TYPE, IDH_CREATE_CLASS_TYPE,
  13. 0,0
  14. };
  15. BEGIN_MESSAGE_MAP(NewClassGeneralPage, CPropertyPage)
  16. ON_MESSAGE(WM_HELP, OnHelp)
  17. ON_MESSAGE(WM_CONTEXTMENU, OnContextHelp)
  18. END_MESSAGE_MAP()
  19. NewClassGeneralPage::NewClassGeneralPage(CreateClassWizardInfo* pWi)
  20. :
  21. CPropertyPage(IDD_CREATE_CLASS_GENERAL),
  22. m_editOID( CParsedEdit::EDIT_TYPE_OID )
  23. {
  24. ASSERT( pWi );
  25. pWiz_info = pWi;
  26. }
  27. BOOL
  28. NewClassGeneralPage::OnInitDialog()
  29. {
  30. CPropertyPage::OnInitDialog();
  31. // load the combo box
  32. HWND combo = ::GetDlgItem(m_hWnd, IDC_CREATE_CLASS_TYPE);
  33. ASSERT( combo );
  34. ComboBox_AddString(combo, g_StructuralClass);
  35. ComboBox_AddString(combo, g_AbstractClass);
  36. ComboBox_AddString(combo, g_AuxClass);
  37. ComboBox_SetCurSel(combo, 0);
  38. // set boundaries
  39. Edit_LimitText(::GetDlgItem(m_hWnd, IDC_CREATE_CLASS_CN), 64);
  40. Edit_LimitText(::GetDlgItem(m_hWnd, IDC_CREATE_CLASS_LDN), 256);
  41. Edit_LimitText(::GetDlgItem(m_hWnd, IDC_CREATE_CLASS_PARENT), 256);
  42. Edit_LimitText(::GetDlgItem(m_hWnd, IDC_DESCRIPTION_EDIT), 256);
  43. m_editOID.SubclassEdit( IDC_CREATE_CLASS_OID, this, cchMaxOID );
  44. return FALSE; // return TRUE unless you set the focus to a control
  45. // EXCEPTION: OCX Property Pages should return FALSE
  46. }
  47. BOOL
  48. NewClassGeneralPage::OnSetActive()
  49. {
  50. CPropertySheet* parent = (CPropertySheet*) GetParent();
  51. parent->SetWizardButtons(PSWIZB_NEXT);
  52. return TRUE;
  53. }
  54. void
  55. Gripe(HWND parent, CEdit* edit, unsigned messageResID)
  56. {
  57. ASSERT(edit);
  58. DoErrMsgBox(parent, TRUE, messageResID);
  59. edit->SetFocus();
  60. edit->SetSel(0, -1);
  61. }
  62. BOOL
  63. NewClassGeneralPage::OnKillActive()
  64. {
  65. // save the settings
  66. GetDlgItemText(IDC_CREATE_CLASS_CN, pWiz_info->cn);
  67. GetDlgItemText(IDC_CREATE_CLASS_LDN, pWiz_info->ldapDisplayName);
  68. GetDlgItemText(IDC_CREATE_CLASS_OID, pWiz_info->oid);
  69. GetDlgItemText(IDC_DESCRIPTION_EDIT, pWiz_info->description);
  70. GetDlgItemText(IDC_CREATE_CLASS_PARENT, pWiz_info->parentClass);
  71. pWiz_info->type = ComboBox_GetCurSel(::GetDlgItem(m_hWnd, IDC_CREATE_CLASS_TYPE));
  72. // validate
  73. // do cn first, as it appears at the top of the page
  74. if (pWiz_info->cn.IsEmpty())
  75. {
  76. Gripe(m_hWnd, (CEdit*) GetDlgItem(IDC_CREATE_CLASS_CN), IDS_MUST_ENTER_CN);
  77. return FALSE;
  78. }
  79. if (pWiz_info->oid.IsEmpty())
  80. {
  81. Gripe(m_hWnd, (CEdit*) GetDlgItem(IDC_CREATE_CLASS_OID), IDS_MUST_ENTER_OID);
  82. return FALSE;
  83. }
  84. //
  85. // Check for valid OID
  86. //
  87. if (pWiz_info->oid.Left(1) == L"." ||
  88. pWiz_info->oid.Right(1) == L"." ||
  89. pWiz_info->oid.Find(L"..") != -1)
  90. {
  91. Gripe( m_hWnd, (CEdit*) GetDlgItem(IDC_CREATE_CLASS_OID), IDS_ERR_CREATE_INVALID_OID );
  92. return FALSE;
  93. }
  94. return TRUE;
  95. }