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.

188 lines
4.0 KiB

  1. // Copyright (c) 2002 Microsoft Corporation
  2. //
  3. // File: UninstallMilestonePage.cpp
  4. //
  5. // Synopsis: Defines the UninstallMilestone Page for the CYS
  6. // wizard
  7. //
  8. // History: 01/24/2002 JeffJon Created
  9. #include "pch.h"
  10. #include "resource.h"
  11. #include "InstallationUnitProvider.h"
  12. #include "UninstallMilestonePage.h"
  13. static PCWSTR UNINSTALL_MILESTONE_PAGE_HELP = L"cys.chm::/remove_role.htm";
  14. UninstallMilestonePage::UninstallMilestonePage()
  15. :
  16. needKillSelection(true),
  17. CYSWizardPage(
  18. IDD_UNINSTALL_MILESTONE_PAGE,
  19. IDS_UNINSTALL_MILESTONE_TITLE,
  20. IDS_UNINSTALL_MILESTONE_SUBTITLE,
  21. UNINSTALL_MILESTONE_PAGE_HELP,
  22. true,
  23. true)
  24. {
  25. LOG_CTOR(UninstallMilestonePage);
  26. }
  27. UninstallMilestonePage::~UninstallMilestonePage()
  28. {
  29. LOG_DTOR(UninstallMilestonePage);
  30. }
  31. void
  32. UninstallMilestonePage::OnInit()
  33. {
  34. LOG_FUNCTION(UninstallMilestonePage::OnInit);
  35. CYSWizardPage::OnInit();
  36. }
  37. bool
  38. UninstallMilestonePage::OnCommand(
  39. HWND windowFrom,
  40. unsigned controlIDFrom,
  41. unsigned code)
  42. {
  43. bool result = false;
  44. switch (controlIDFrom)
  45. {
  46. case IDC_UNINSTALL_CHECK:
  47. if (code == BN_CLICKED)
  48. {
  49. bool checked =
  50. Win::Button_GetCheck(
  51. Win::GetDlgItem(hwnd, IDC_UNINSTALL_CHECK));
  52. Win::PropSheet_SetWizButtons(
  53. Win::GetParent(hwnd),
  54. (checked) ? PSWIZB_NEXT | PSWIZB_BACK : PSWIZB_BACK);
  55. }
  56. break;
  57. case IDC_MILESTONE_EDIT:
  58. if (code == EN_SETFOCUS &&
  59. needKillSelection)
  60. {
  61. Win::Edit_SetSel(windowFrom, -1, -1);
  62. needKillSelection = false;
  63. }
  64. break;
  65. default:
  66. break;
  67. }
  68. return result;
  69. }
  70. bool
  71. UninstallMilestonePage::OnSetActive()
  72. {
  73. LOG_FUNCTION(UninstallMilestonePage::OnSetActive);
  74. // Always clear the checkbox when returning to this page.
  75. // We want to force the user to select for uninstall
  76. Win::Button_SetCheck(
  77. Win::GetDlgItem(hwnd, IDC_UNINSTALL_CHECK),
  78. BST_UNCHECKED);
  79. Win::PropSheet_SetWizButtons(
  80. Win::GetParent(hwnd),
  81. PSWIZB_BACK);
  82. InstallationUnit& currentInstallationUnit =
  83. InstallationUnitProvider::GetInstance().GetCurrentInstallationUnit();
  84. // Get the finish text from the installation unit and put it in the finish box
  85. String message;
  86. bool changes =
  87. currentInstallationUnit.GetUninstallMilestoneText(message);
  88. if (!changes)
  89. {
  90. message = String::load(IDS_FINISH_NO_CHANGES);
  91. }
  92. Win::SetDlgItemText(
  93. hwnd,
  94. IDC_MILESTONE_EDIT,
  95. message);
  96. String warning =
  97. currentInstallationUnit.GetUninstallWarningText();
  98. Win::SetDlgItemText(
  99. hwnd,
  100. IDC_UNINSTALL_WARNING_STATIC,
  101. warning);
  102. String checkboxText =
  103. currentInstallationUnit.GetUninstallCheckboxText();
  104. Win::SetDlgItemText(
  105. hwnd,
  106. IDC_UNINSTALL_CHECK,
  107. checkboxText);
  108. if (!changes)
  109. {
  110. popup.MessageBox(
  111. hwnd,
  112. IDS_NO_CHANGES_MESSAGEBOX_TEXT,
  113. MB_OK | MB_ICONWARNING);
  114. }
  115. // Remove the selection of the edit box
  116. Win::Edit_SetSel(
  117. Win::GetDlgItem(
  118. hwnd,
  119. IDC_MILESTONE_EDIT),
  120. -1,
  121. 0);
  122. Win::PostMessage(
  123. hwnd,
  124. WM_NEXTDLGCTL,
  125. (WPARAM) Win::GetDlgItem(hwnd, IDC_UNINSTALL_CHECK),
  126. TRUE);
  127. return true;
  128. }
  129. int
  130. UninstallMilestonePage::Validate()
  131. {
  132. LOG_FUNCTION(UninstallMilestonePage::Validate);
  133. Win::WaitCursor wait;
  134. int nextPage = -1;
  135. if (!InstallationUnitProvider::GetInstance().
  136. GetCurrentInstallationUnit().DoInstallerCheck(hwnd))
  137. {
  138. nextPage = IDD_UNINSTALL_PROGRESS_PAGE;
  139. }
  140. LOG(String::format(
  141. L"nextPage = %1!d!",
  142. nextPage));
  143. return nextPage;
  144. }