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.

145 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: cenable.cpp
  7. //
  8. // Contents: implementation of CConfigEnable
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "CEnable.h"
  14. #include "util.h"
  15. #include "regvldlg.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CConfigEnable dialog
  23. CConfigEnable::CConfigEnable(UINT nTemplateID)
  24. : CAttribute(nTemplateID ? nTemplateID : IDD)
  25. {
  26. //{{AFX_DATA_INIT(CConfigEnable)
  27. m_nEnabledRadio = -1;
  28. //}}AFX_DATA_INIT
  29. m_fNotDefine = TRUE;
  30. m_pHelpIDs = (DWORD_PTR)a182HelpIDs;
  31. m_uTemplateResID = IDD;
  32. }
  33. void CConfigEnable::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CAttribute::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CConfigEnable)
  37. DDX_Radio(pDX, IDC_ENABLED, m_nEnabledRadio);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CConfigEnable, CAttribute)
  41. //{{AFX_MSG_MAP(CConfigEnable)
  42. ON_BN_CLICKED(IDC_DISABLED, OnDisabled)
  43. ON_BN_CLICKED(IDC_ENABLED, OnEnabled)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CConfigEnable message handlers
  48. void CConfigEnable::Initialize(CResult *pResult)
  49. {
  50. CAttribute::Initialize(pResult);
  51. LONG_PTR dw = pResult->GetBase();
  52. if ( (LONG_PTR)ULongToPtr(SCE_NO_VALUE) == dw ||
  53. (BYTE)SCE_NO_VALUE == (BYTE)dw )
  54. {
  55. m_bConfigure = FALSE;
  56. }
  57. else
  58. {
  59. m_bConfigure = TRUE;
  60. //
  61. // BUG 145561 - dw is 0 vs non-0 boolean, not 0 vs 1
  62. //
  63. SetInitialValue((DWORD_PTR)(dw != 0));
  64. }
  65. }
  66. void CConfigEnable::SetInitialValue(DWORD_PTR dw) {
  67. //
  68. // Make sure we only set the INITIAL value and
  69. // don't reset an already-set value.
  70. //
  71. if (-1 == m_nEnabledRadio && m_fNotDefine) //Raid #413225, 6/11/2001, Yanggao
  72. {
  73. if( (DWORD_PTR)ULongToPtr(SCE_NO_VALUE) == dw ) //Raid #403460
  74. {
  75. return;
  76. }
  77. m_nEnabledRadio = (dw ? 0 : 1);
  78. }
  79. }
  80. BOOL CConfigEnable::OnApply()
  81. {
  82. if ( !m_bReadOnly )
  83. {
  84. LONG_PTR dw=0;
  85. UpdateData(TRUE);
  86. if (!m_bConfigure)
  87. dw = (LONG_PTR)ULongToPtr(SCE_NO_VALUE);
  88. else
  89. {
  90. switch(m_nEnabledRadio)
  91. {
  92. // ENABLED
  93. case 0:
  94. dw = 1;
  95. break;
  96. // DISABLED
  97. case 1:
  98. dw = 0;
  99. break;
  100. }
  101. }
  102. m_pData->SetBase(dw);
  103. SetProfileInfo(m_pData->GetID(),dw,m_pData->GetBaseProfile());
  104. m_pData->Update(m_pSnapin);
  105. }
  106. return CAttribute::OnApply();
  107. }
  108. BOOL CConfigEnable::OnInitDialog()
  109. {
  110. CAttribute::OnInitDialog();
  111. AddUserControl(IDC_ENABLED);
  112. AddUserControl(IDC_DISABLED);
  113. OnConfigure();
  114. return TRUE; // return TRUE unless you set the focus to a control
  115. // EXCEPTION: OCX Property Pages should return FALSE
  116. }
  117. void CConfigEnable::OnDisabled()
  118. {
  119. SetModified(TRUE);
  120. }
  121. void CConfigEnable::OnEnabled()
  122. {
  123. SetModified(TRUE);
  124. }