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.

117 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: lchoice.cpp
  7. //
  8. // Contents: implementation of CLocalPolChoice
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "snapmgr.h"
  14. #include "attr.h"
  15. #include "LChoice.h"
  16. #include "util.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CLocalPolChoice dialog
  24. CLocalPolChoice::CLocalPolChoice()
  25. : CConfigChoice(IDD)
  26. {
  27. //{{AFX_DATA_INIT(CLocalPolChoice)
  28. //}}AFX_DATA_INIT
  29. m_pHelpIDs = (DWORD_PTR)a235HelpIDs;
  30. m_uTemplateResID = IDD;
  31. }
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CLocalPolChoice message handlers
  34. BOOL CLocalPolChoice::OnInitDialog()
  35. {
  36. CConfigChoice::OnInitDialog();
  37. PSCE_REGISTRY_VALUE_INFO prv = (PSCE_REGISTRY_VALUE_INFO)(m_pData->GetBase());
  38. if (!prv ) //Raid 372939, 4/20/2001
  39. {
  40. m_cbChoices.SetCurSel(-1);
  41. }
  42. else //Raid #457885, Yang Gao, 8/21/2001
  43. {
  44. if( prv->Value == NULL )
  45. {
  46. m_cbChoices.SetCurSel(-1);
  47. m_bConfigure = TRUE;
  48. UpdateData(FALSE); //Raid #480375, Yanggao, 10/12/2001
  49. EnableUserControls(m_bConfigure);
  50. }
  51. }
  52. OnSelchangeChoices();
  53. return TRUE;
  54. }
  55. BOOL CLocalPolChoice::OnApply()
  56. {
  57. if ( !m_bReadOnly )
  58. {
  59. DWORD dw = 0;
  60. int nIndex = 0;
  61. UpdateData(TRUE);
  62. if (m_bConfigure)
  63. {
  64. nIndex = m_cbChoices.GetCurSel();
  65. if (CB_ERR != nIndex)
  66. dw = (DWORD) m_cbChoices.GetItemData(nIndex);
  67. PSCE_REGISTRY_VALUE_INFO prv=(PSCE_REGISTRY_VALUE_INFO)(m_pData->GetBase());
  68. //
  69. // this address should never be NULL
  70. //
  71. if ( prv )
  72. {
  73. PWSTR pTmp=NULL;
  74. if ( dw != SCE_NO_VALUE )
  75. {
  76. CString strTmp;
  77. // allocate buffer
  78. strTmp.Format(TEXT("%d"), dw);
  79. pTmp = (PWSTR)LocalAlloc(0, (strTmp.GetLength()+1)*sizeof(TCHAR));
  80. if ( pTmp )
  81. //This may not be a safe usage. using WCHAR instead of TCHAR. Consider fix.
  82. wcscpy(pTmp,(LPCTSTR)strTmp);
  83. else
  84. {
  85. // can't allocate buffer, error!!
  86. return FALSE;
  87. }
  88. }
  89. if ( prv->Value )
  90. LocalFree(prv->Value);
  91. prv->Value = pTmp;
  92. m_pSnapin->UpdateLocalPolRegValue(m_pData);
  93. }
  94. }
  95. }
  96. // Class hieirarchy is bad - call CAttribute base method directly
  97. return CAttribute::OnApply();
  98. }