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.

155 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: aenable.cpp
  7. //
  8. // Contents: implementation of CAttrEnable
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "attr.h"
  14. #include "snapmgr.h"
  15. #include "AEnable.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. // CAttrEnable dialog
  24. CAttrEnable::CAttrEnable(UINT nTemplateID)
  25. : CAttribute(nTemplateID ? nTemplateID : IDD)
  26. {
  27. //{{AFX_DATA_INIT(CAttrEnable)
  28. m_Current = _T("");
  29. m_EnabledRadio = -1;
  30. m_Title = _T("");
  31. //}}AFX_DATA_INIT
  32. m_pHelpIDs = (DWORD_PTR)a169HelpIDs;
  33. m_uTemplateResID = IDD;
  34. }
  35. void CAttrEnable::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CAttribute::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CAttrEnable)
  39. DDX_Text(pDX, IDC_CURRENT, m_Current);
  40. DDX_Radio(pDX, IDC_ENABLED, m_EnabledRadio);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAttrEnable, CAttribute)
  44. //{{AFX_MSG_MAP(CAttrEnable)
  45. ON_BN_CLICKED(IDC_ENABLED, OnRadio)
  46. ON_BN_CLICKED(IDC_DISABLED, OnRadio)
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CAttrEnable message handlers
  51. void CAttrEnable::Initialize(CResult * pResult)
  52. {
  53. CString str;
  54. CAttribute::Initialize(pResult);
  55. LONG_PTR dw = pResult->GetBase();
  56. if ( (LONG_PTR)ULongToPtr(SCE_NO_VALUE) == dw ||
  57. (BYTE)SCE_NO_VALUE == (BYTE)dw )
  58. {
  59. m_bConfigure = FALSE;
  60. }
  61. else
  62. {
  63. m_bConfigure = TRUE;
  64. //
  65. // BUG 145561 - dw is 0 vs non-0 boolean, not 0 vs 1
  66. //
  67. SetInitialValue((DWORD_PTR)(dw != 0));
  68. }
  69. pResult->GetDisplayName( NULL, m_Current, 2 );
  70. }
  71. void CAttrEnable::SetInitialValue(DWORD_PTR dw)
  72. {
  73. if (-1 == m_EnabledRadio)
  74. {
  75. m_EnabledRadio = dw ? 0 : 1;
  76. }
  77. }
  78. void CAttrEnable::OnRadio()
  79. {
  80. UpdateData(TRUE);
  81. CWnd *bnOK;
  82. SetModified(TRUE);
  83. bnOK = GetDlgItem(IDOK);
  84. if (bnOK ) {
  85. bnOK->EnableWindow(-1 != m_EnabledRadio);
  86. }
  87. }
  88. BOOL CAttrEnable::OnApply()
  89. {
  90. if ( !m_bReadOnly )
  91. {
  92. int status = 0;
  93. UpdateData(TRUE);
  94. DWORD dw = 0;
  95. if (!m_bConfigure)
  96. dw = SCE_NO_VALUE;
  97. else
  98. {
  99. switch(m_EnabledRadio)
  100. {
  101. // ENABLED
  102. case 0:
  103. dw = 1;
  104. break;
  105. // DISABLED
  106. case 1:
  107. dw = 0;
  108. break;
  109. default:
  110. dw = SCE_NO_VALUE;
  111. break;
  112. }
  113. }
  114. m_pData->SetBase((LONG_PTR)ULongToPtr(dw));
  115. status = m_pSnapin->SetAnalysisInfo(m_pData->GetID(),(LONG_PTR)ULongToPtr(dw), m_pData);
  116. m_pData->SetStatus(status);
  117. m_pData->Update(m_pSnapin);
  118. }
  119. return CAttribute::OnApply();
  120. }
  121. BOOL CAttrEnable::OnInitDialog()
  122. {
  123. CAttribute::OnInitDialog();
  124. AddUserControl(IDC_ENABLED);
  125. AddUserControl(IDC_DISABLED);
  126. OnConfigure();
  127. OnRadio();
  128. return TRUE; // return TRUE unless you set the focus to a control
  129. // EXCEPTION: OCX Property Pages should return FALSE
  130. }