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.

106 lines
2.5 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. OnSelchangeChoices();
  43. return TRUE;
  44. }
  45. BOOL CLocalPolChoice::OnApply()
  46. {
  47. if ( !m_bReadOnly )
  48. {
  49. DWORD dw = 0;
  50. int nIndex = 0;
  51. UpdateData(TRUE);
  52. if (m_bConfigure)
  53. {
  54. nIndex = m_cbChoices.GetCurSel();
  55. if (CB_ERR != nIndex)
  56. dw = (DWORD) m_cbChoices.GetItemData(nIndex);
  57. PSCE_REGISTRY_VALUE_INFO prv=(PSCE_REGISTRY_VALUE_INFO)(m_pData->GetBase());
  58. //
  59. // this address should never be NULL
  60. //
  61. if ( prv )
  62. {
  63. PWSTR pTmp=NULL;
  64. if ( dw != SCE_NO_VALUE )
  65. {
  66. CString strTmp;
  67. // allocate buffer
  68. strTmp.Format(TEXT("%d"), dw);
  69. pTmp = (PWSTR)LocalAlloc(0, (strTmp.GetLength()+1)*sizeof(TCHAR));
  70. if ( pTmp )
  71. wcscpy(pTmp,(LPCTSTR)strTmp);
  72. else
  73. {
  74. // can't allocate buffer, error!!
  75. return FALSE;
  76. }
  77. }
  78. if ( prv->Value )
  79. LocalFree(prv->Value);
  80. prv->Value = pTmp;
  81. m_pSnapin->UpdateLocalPolRegValue(m_pData);
  82. }
  83. }
  84. }
  85. // Class hieirarchy is bad - call CAttribute base method directly
  86. return CAttribute::OnApply();
  87. }