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.

157 lines
4.4 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "pgWizOpt.h"
  6. #include "w95trace.h"
  7. BOOL IsAdmin();
  8. CWizardOptionsPg::CWizardOptionsPg(
  9. LPPROPSHEETPAGE ppsp
  10. ) : WizardPage(ppsp, IDS_WIZOPTTITLE, IDS_WIZOPTSUBTITLE)
  11. {
  12. m_dwPageId = IDD_WIZOPTIONS;
  13. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  14. restoreOpt = FALSE;
  15. }
  16. CWizardOptionsPg::~CWizardOptionsPg(
  17. VOID
  18. )
  19. {
  20. }
  21. DWORD g_rgdwWizNoOptionsSelected[] = {IDD_WIZNOOPTIONSSELECTED};
  22. DWORD g_rgdwWizDoBlind[] = {
  23. IDD_FNTWIZSCROLLBAR, // scroll bar
  24. IDD_PREV_ICON2,
  25. IDD_PREV_COLOR,
  26. IDD_MSEWIZMOUSECURSOR,
  27. IDD_CARET
  28. };
  29. DWORD g_rgdwWizDoSounds[] = {
  30. IDD_SNDWIZSENTRYSHOWSOUNDS,
  31. IDD_SNDWIZSENTRYSHOWSOUNDS2,
  32. };
  33. DWORD g_rgdwWizDoKeyboardMouse[] = {
  34. IDD_KBDWIZSTICKYKEYS,
  35. IDD_KBDWIZFILTERKEYS1,
  36. IDD_KBDWIZFILTERKEYS2,
  37. IDD_KBDWIZTOGGLEKEYS,
  38. IDD_KBDWIZSHOWEXTRAKEYBOARDHELP,
  39. IDD_MSEWIZMOUSEKEYS,
  40. IDD_MSEWIZMOUSECURSOR,
  41. IDD_MSEWIZBUTTONCONFIG,
  42. IDD_MSEWIZMOUSESPEED
  43. };
  44. DWORD g_rgdwWizDoAdmin[] = {
  45. IDD_WIZACCESSTIMEOUT,
  46. IDD_WIZWORKSTATIONDEFAULT
  47. };
  48. DWORD g_rgdwWizFinalPages[] = {
  49. IDD_WIZFINISH
  50. };
  51. BOOL CWizardOptionsPg::AdjustWizPageOrder()
  52. {
  53. BOOL bDoBlind = Button_GetCheck(GetDlgItem(m_hwnd, IDC_DOBLIND));
  54. BOOL bDoSounds = Button_GetCheck(GetDlgItem(m_hwnd, IDC_DOSOUND));
  55. BOOL bDoKeyboardMouse = Button_GetCheck(GetDlgItem(m_hwnd, IDC_DOKEYBOARDMOUSE));
  56. BOOL bDoAdmin = Button_GetCheck(GetDlgItem(m_hwnd, IDC_DOADMIN));
  57. BOOL bDoNoOptions = (!bDoBlind && !bDoSounds && !bDoKeyboardMouse && !bDoAdmin && !restoreOpt);
  58. // First remove all possible pages since we want to insert them in the correct order
  59. // Return value does not matter since the pages may not be in the array
  60. sm_WizPageOrder.RemovePages(g_rgdwWizNoOptionsSelected, ARRAYSIZE(g_rgdwWizNoOptionsSelected));
  61. sm_WizPageOrder.RemovePages(g_rgdwWizDoBlind, ARRAYSIZE(g_rgdwWizDoBlind));
  62. sm_WizPageOrder.RemovePages(g_rgdwWizDoSounds, ARRAYSIZE(g_rgdwWizDoSounds));
  63. sm_WizPageOrder.RemovePages(g_rgdwWizDoKeyboardMouse, ARRAYSIZE(g_rgdwWizDoKeyboardMouse));
  64. sm_WizPageOrder.RemovePages(g_rgdwWizDoAdmin, ARRAYSIZE(g_rgdwWizDoAdmin));
  65. sm_WizPageOrder.RemovePages(g_rgdwWizFinalPages, ARRAYSIZE(g_rgdwWizFinalPages));
  66. // Then Add in pages in groups in the reverse order that we want them to appear.
  67. // We do them this way since they are inserted after this page, so the first group inserted
  68. // will be the last group at the end of this.
  69. // NOTE: We do not care about the return value from AddPages() in the sense
  70. // that we they do not allocate or free memory so it does not hurt to keep calling them. We
  71. // Will propogate a return value of FALSE if any of them fail.
  72. BOOL bSuccess = TRUE;
  73. // Add Final Pages
  74. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizFinalPages, ARRAYSIZE(g_rgdwWizFinalPages));
  75. if(bDoNoOptions)
  76. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizNoOptionsSelected, ARRAYSIZE(g_rgdwWizNoOptionsSelected));
  77. if(bDoAdmin)
  78. {
  79. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizDoAdmin, ARRAYSIZE(g_rgdwWizDoAdmin));
  80. // Incase you are NOT an admin Remove admin page
  81. if ( !IsAdmin() )
  82. sm_WizPageOrder.RemovePages(&g_rgdwWizDoAdmin[1], 1);
  83. }
  84. if(bDoKeyboardMouse)
  85. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizDoKeyboardMouse, ARRAYSIZE(g_rgdwWizDoKeyboardMouse));
  86. if(bDoSounds)
  87. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizDoSounds, ARRAYSIZE(g_rgdwWizDoSounds));
  88. if(bDoBlind)
  89. bSuccess = bSuccess && sm_WizPageOrder.AddPages(m_dwPageId, g_rgdwWizDoBlind, ARRAYSIZE(g_rgdwWizDoBlind));
  90. return bSuccess;
  91. }
  92. LRESULT
  93. CWizardOptionsPg::OnCommand(
  94. HWND hwnd,
  95. WPARAM wParam,
  96. LPARAM lParam
  97. )
  98. {
  99. LRESULT lResult = 1;
  100. WORD wNotifyCode = HIWORD(wParam);
  101. WORD wCtlID = LOWORD(wParam);
  102. HWND hwndCtl = (HWND)lParam;
  103. switch(wCtlID)
  104. {
  105. case IDC_BTNRESTORETODEFAULT:
  106. g_Options.ApplyWindowsDefault();
  107. restoreOpt = TRUE;
  108. break;
  109. default:
  110. break;
  111. }
  112. return lResult;
  113. }
  114. BOOL IsAdmin()
  115. {
  116. HKEY hkey;
  117. BOOL fOk = (ERROR_SUCCESS == RegOpenKeyExA( HKEY_USERS, ".Default", 0, KEY_ALL_ACCESS, &hkey ));
  118. if(fOk)
  119. {
  120. RegCloseKey(hkey);
  121. }
  122. return fOk;
  123. }