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.

186 lines
4.5 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. //Raid #651344, yanggao, 8/9/2002
  112. long hID = m_pData->GethID();
  113. if( (hID >= IDS_SYS_LOG_GUEST && hID<= IDS_APP_LOG_GUEST) ||
  114. (IDS_FORCE_LOGOFF == hID ) )
  115. {
  116. CWnd *pWarn = GetDlgItem(IDC_WARNING);
  117. if (pWarn)
  118. {
  119. CString strWarning;
  120. switch(hID)
  121. {
  122. case IDS_SYS_LOG_GUEST:
  123. case IDS_SEC_LOG_GUEST:
  124. case IDS_APP_LOG_GUEST:
  125. strWarning.LoadString(IDS_EVENTLOG_WARNING);
  126. break;
  127. case IDS_FORCE_LOGOFF: //Raid #753618, yanggao, 12/23/2002
  128. strWarning.LoadString(IDS_FORCE_LOGOFF_WARNING);
  129. break;
  130. }
  131. pWarn->SetWindowText(strWarning);
  132. pWarn->ShowWindow(SW_SHOW);
  133. pWarn = GetDlgItem(IDC_WARNING_ICON);
  134. if (pWarn)
  135. {
  136. pWarn->ShowWindow(SW_SHOW);
  137. }
  138. }
  139. }
  140. AddUserControl(IDC_ENABLED);
  141. AddUserControl(IDC_DISABLED);
  142. OnConfigure();
  143. return TRUE; // return TRUE unless you set the focus to a control
  144. // EXCEPTION: OCX Property Pages should return FALSE
  145. }
  146. void CConfigEnable::OnDisabled()
  147. {
  148. int prevValue = m_nEnabledRadio; //Raid #490995, Yanggao
  149. UpdateData();
  150. if(m_nEnabledRadio != prevValue)
  151. {
  152. SetModified(TRUE);
  153. }
  154. }
  155. void CConfigEnable::OnEnabled()
  156. {
  157. int prevValue = m_nEnabledRadio; //Raid #490995, Yanggao
  158. UpdateData();
  159. if(m_nEnabledRadio != prevValue)
  160. {
  161. SetModified(TRUE);
  162. }
  163. }