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.

194 lines
4.9 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1997.
  5. //
  6. // File: cnfgpsht.cpp
  7. //
  8. // Contents: Implements class COlecnfgPropertySheet
  9. //
  10. // Classes:
  11. //
  12. // Methods: COlecnfgPropertySheet::COlecnfgPropertySheet
  13. // COlecnfgPropertySheet::~COlecnfgPropertySheet
  14. // COlecnfgPropertySheet::DoModal
  15. // COlecnfgPropertySheet::Create
  16. // COlecnfgPropertySheet::OnNcCreate
  17. // COlecnfgPropertySheet::OnCommand
  18. //
  19. // History: 23-Apr-96 BruceMa Created.
  20. //
  21. //----------------------------------------------------------------------
  22. #include "stdafx.h"
  23. #include "afxtempl.h"
  24. #include "resource.h"
  25. #include "cstrings.h"
  26. #include "creg.h"
  27. #include "types.h"
  28. #include "datapkt.h"
  29. #if !defined(STANDALONE_BUILD)
  30. extern "C"
  31. {
  32. #include <getuser.h>
  33. }
  34. #endif
  35. #include "util.h"
  36. #include "virtreg.h"
  37. #include "CnfgPSht.h"
  38. #ifdef _DEBUG
  39. #define new DEBUG_NEW
  40. #undef THIS_FILE
  41. static char BASED_CODE THIS_FILE[] = __FILE__;
  42. #endif
  43. /////////////////////////////////////////////////////////////////////////////
  44. // COlecnfgPropertySheet
  45. IMPLEMENT_DYNAMIC(COlecnfgPropertySheet, CPropertySheet)
  46. COlecnfgPropertySheet::COlecnfgPropertySheet(CWnd* pWndParent)
  47. : CPropertySheet(IDS_PROPSHT_CAPTION, pWndParent)
  48. {
  49. // Set the title
  50. CString sTitle;
  51. sTitle.LoadString(IDS_PSMAIN_TITLE);
  52. SetTitle(sTitle, PSH_PROPTITLE);
  53. // Add all of the property pages here. Note that
  54. // the order that they appear in here will be
  55. // the order they appear in on screen. By default,
  56. // the first page of the set is the active one.
  57. // One way to make a different property page the
  58. // active one is to call SetActivePage().
  59. // Disable property sheet help button
  60. m_psh.dwFlags &= ~PSH_HASHELP;
  61. m_Page1.m_psp.dwFlags &= ~PSH_HASHELP;
  62. m_Page2.m_psp.dwFlags &= ~PSH_HASHELP;
  63. m_Page3.m_psp.dwFlags &= ~PSH_HASHELP;
  64. #ifndef _CHICAGO_
  65. m_Page4.m_psp.dwFlags &= ~PSH_HASHELP;
  66. #endif
  67. AddPage(&m_Page1);
  68. AddPage(&m_Page2);
  69. AddPage(&m_Page3);
  70. #ifndef _CHICAGO_
  71. AddPage(&m_Page4);
  72. #endif
  73. }
  74. COlecnfgPropertySheet::~COlecnfgPropertySheet()
  75. {
  76. }
  77. BEGIN_MESSAGE_MAP(COlecnfgPropertySheet, CPropertySheet)
  78. //{{AFX_MSG_MAP(COlecnfgPropertySheet)
  79. ON_WM_NCCREATE()
  80. ON_WM_DESTROY()
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. // COlecnfgPropertySheet message handlers
  85. INT_PTR COlecnfgPropertySheet::DoModal()
  86. {
  87. return CPropertySheet::DoModal();
  88. }
  89. BOOL COlecnfgPropertySheet::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  90. {
  91. return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  92. }
  93. BOOL COlecnfgPropertySheet::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
  94. {
  95. if (!CPropertySheet::OnNcCreate(lpCreateStruct))
  96. return FALSE;
  97. // Enable context help
  98. ModifyStyleEx(0, WS_EX_CONTEXTHELP);
  99. return TRUE;
  100. }
  101. BOOL COlecnfgPropertySheet::OnCommand(WPARAM wParam, LPARAM lParam)
  102. {
  103. // TODO: Add your specialized code here and/or call the base class
  104. switch (LOWORD(wParam))
  105. {
  106. case IDOK:
  107. case ID_APPLY_NOW:
  108. g_virtreg.ApplyAll();
  109. // Check whether the user changed something that requires a notification to DCOM
  110. if (g_fReboot)
  111. {
  112. g_util.UpdateDCOMInfo();
  113. // With the above interface to the SCM we don't have to ask the
  114. // user whether to reboot. However, I'll keep the code for
  115. // posterity.
  116. /*
  117. CString sCaption;
  118. CString sMessage;
  119. sCaption.LoadString(IDS_SYSTEMMESSAGE);
  120. sMessage.LoadString(IDS_REBOOT);
  121. if (MessageBox(sMessage, sCaption, MB_YESNO) == IDYES)
  122. {
  123. if (g_util.AdjustPrivilege(SE_SHUTDOWN_NAME))
  124. {
  125. // Now reboot
  126. ExitWindowsEx(EWX_REBOOT, 0);
  127. }
  128. }
  129. */
  130. }
  131. break;
  132. }
  133. return CPropertySheet::OnCommand(wParam, lParam);
  134. }
  135. void COlecnfgPropertySheet::OnDestroy()
  136. {
  137. CPropertySheet::OnDestroy();
  138. if (g_fReboot)
  139. {
  140. // On NT, with the above interface to the SCM (UpdateDCOMInfo)
  141. // we don't have to ask the user whether to reboot.
  142. #ifdef _CHICAGO_
  143. CString sCaption;
  144. CString sMessage;
  145. sCaption.LoadString(IDS_SYSTEMMESSAGE);
  146. sMessage.LoadString(IDS_PERHAPSREBOOT);
  147. sMessage.LoadString(IDS_REBOOT);
  148. if (MessageBox(sMessage, sCaption, MB_YESNO) == IDYES)
  149. {
  150. // if (g_util.AdjustPrivilege(SE_SHUTDOWN_NAME))
  151. // {
  152. // Now reboot
  153. ExitWindowsEx(EWX_REBOOT, 0);
  154. // }
  155. }
  156. #endif
  157. }
  158. }