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.

138 lines
2.8 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: Dialogs.cpp
  4. //
  5. // Synopsis: Defines some helpful dialogs that are
  6. // used throughout the wizard
  7. //
  8. // History: 05/02/2001 JeffJon Created
  9. #include "pch.h"
  10. #include "resource.h"
  11. #include "Dialogs.h"
  12. DWORD finishDialogHelpMap[] =
  13. {
  14. 0, 0
  15. };
  16. FinishDialog::FinishDialog(
  17. String logFile,
  18. String helpStringURL)
  19. : logFileName(logFile),
  20. helpString(helpStringURL),
  21. showHelpList(true),
  22. showLogFile(false),
  23. Dialog(IDD_SUCCESS_DIALOG, finishDialogHelpMap)
  24. {
  25. LOG_CTOR(FinishDialog);
  26. }
  27. void
  28. FinishDialog::OnInit()
  29. {
  30. LOG_FUNCTION(FinishDialog::OnInit);
  31. // load the log file format string
  32. String logCheckTextFormat = String::load(IDS_OPEN_LOG_FORMAT_STRING);
  33. String logCheckText = String::format(
  34. logCheckTextFormat,
  35. logFileName.c_str());
  36. Win::SetWindowText(
  37. Win::GetDlgItem(hwnd, IDC_LOG_FILE_CHECK), logCheckText);
  38. // set the checkboxes to the defaults
  39. Win::Button_SetCheck(
  40. Win::GetDlgItem(hwnd, IDC_HELP_LIST_CHECK),
  41. showHelpList ? BST_CHECKED : BST_UNCHECKED);
  42. Win::Button_SetCheck(
  43. Win::GetDlgItem(hwnd, IDC_LOG_FILE_CHECK),
  44. showLogFile ? BST_CHECKED : BST_UNCHECKED);
  45. }
  46. bool
  47. FinishDialog::OnCommand(
  48. HWND /*windowFrom*/,
  49. unsigned controlIdFrom,
  50. unsigned code)
  51. {
  52. // LOG_FUNCTION(FinishDialog::OnCommand);
  53. bool result = false;
  54. if (IDOK == controlIdFrom &&
  55. BN_CLICKED == code)
  56. {
  57. showHelpList = Win::Button_GetCheck(
  58. Win::GetDlgItem(hwnd, IDC_HELP_LIST_CHECK));
  59. showLogFile = Win::Button_GetCheck(
  60. Win::GetDlgItem(hwnd, IDC_LOG_FILE_CHECK));
  61. if (showLogFile)
  62. {
  63. OpenLogFile();
  64. }
  65. if (showHelpList)
  66. {
  67. OnHelp();
  68. }
  69. Win::EndDialog(hwnd, IDOK);
  70. result = true;
  71. }
  72. else if (IDCANCEL == controlIdFrom &&
  73. BN_CLICKED == code)
  74. {
  75. Win::EndDialog(hwnd, IDCANCEL);
  76. result = true;
  77. }
  78. return result;
  79. }
  80. void
  81. FinishDialog::OpenLogFile()
  82. {
  83. LOG_FUNCTION(FinishDialog::OpenLogFile);
  84. String commandLine = L"notepad.exe ";
  85. commandLine += logFileName;
  86. DWORD exitCode = 0;
  87. HRESULT hr = CreateAndWaitForProcess(commandLine, exitCode);
  88. ASSERT(SUCCEEDED(hr));
  89. }
  90. bool
  91. FinishDialog::OnHelp()
  92. {
  93. LOG_FUNCTION(FinishDialog::OnHelp);
  94. // NOTE: I am not using Win::HtmlHelp here so that the help
  95. // is actually running in a different process. This
  96. // allows us to close down CYS without losing the help
  97. // window.
  98. String commandline = L"hh.exe " + helpString;
  99. HRESULT hr = MyCreateProcess(commandline);
  100. if (FAILED(hr))
  101. {
  102. LOG(String::format(
  103. L"Failed to open help: hr = 0x%1!x!",
  104. hr));
  105. }
  106. return true;
  107. }