/3rd_party/wtl/Samples/Wizard97Test/Wizard/TestWizardCompletionPage.cpp

https://code.google.com/p/softart/ · C++ · 158 lines · 109 code · 27 blank · 22 comment · 2 complexity · 9e6163e5dd84f306f3982d301a325d0b MD5 · raw file

  1. #include "stdafx.h"
  2. #include "TestWizardCompletionPage.h"
  3. LRESULT CTestWizardCompletionPage::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  4. {
  5. this->InitializeControls();
  6. this->InitializeValues();
  7. return 1;
  8. }
  9. void CTestWizardCompletionPage::InitializeFont(void)
  10. {
  11. // Set the font
  12. CLogFont logFont;
  13. CClientDC dc(m_hWnd);
  14. logFont.SetHeight(8, dc);
  15. ::lstrcpy(logFont.lfFaceName, _T("Courier New"));
  16. m_fontSummary.Attach(logFont.CreateFontIndirect());
  17. m_editSummary.SetFont(m_fontSummary);
  18. // Set the tab stops to 4 characters.
  19. // Tab stops are in dialog units.
  20. TEXTMETRIC tm = {0};
  21. CFontHandle oldFont = dc.SelectFont(m_fontSummary);
  22. dc.GetTextMetrics(&tm);
  23. dc.SelectFont(oldFont);
  24. int dialogUnitsX = ::MulDiv(4, tm.tmAveCharWidth, LOWORD(GetDialogBaseUnits()));
  25. int tabStops = 4*dialogUnitsX;
  26. m_editSummary.SetTabStops(tabStops);
  27. }
  28. void CTestWizardCompletionPage::InitializeControls(void)
  29. {
  30. CFontHandle fontExteriorPageTitleFont(baseClass::GetExteriorPageTitleFont());
  31. CWindow title = this->GetDlgItem(IDC_WIZ97_EXTERIOR_TITLE);
  32. title.SetFont(fontExteriorPageTitleFont);
  33. m_editSummary = this->GetDlgItem(IDC_WIZ97_SUMMARY);
  34. this->InitializeFont();
  35. }
  36. void CTestWizardCompletionPage::InitializeValues(void)
  37. {
  38. }
  39. void CTestWizardCompletionPage::UpdateSummary(void)
  40. {
  41. CString path = m_pTestWizardInfo->GetPath();
  42. bool recurse = m_pTestWizardInfo->GetRecurse();
  43. CString filter = m_pTestWizardInfo->GetFilter();
  44. TestWizardOutputType outputType = m_pTestWizardInfo->GetOutputType();
  45. CString text;
  46. text.Format(
  47. _T("Test Wizard: \r\n")
  48. _T("? Find files in the directory:\r\n")
  49. _T("\t%s\r\n")
  50. _T("? %s\r\n")
  51. _T("? Find files matching the filter '%s'\r\n"),
  52. path,
  53. recurse ? _T("Also search sub-directories") : _T("Only search that directory"),
  54. filter);
  55. m_editSummary.SetWindowText(text);
  56. CString outputDescription;
  57. switch(outputType)
  58. {
  59. case eOutput_SendEMail:
  60. outputDescription =
  61. _T("? Send the file list in an e-mail\r\n")
  62. _T(" (using the default mail client)\r\n");
  63. break;
  64. case eOutput_SaveToFile:
  65. {
  66. CString outputFileName = m_pTestWizardInfo->GetOutputFileName();
  67. TestWizardOutputFileEncoding outputFileEncoding = m_pTestWizardInfo->GetOutputFileEncoding();
  68. outputDescription.Format(
  69. _T("? Save the file list to the file:\r\n")
  70. _T("\t%s\r\n"),
  71. outputFileName);
  72. switch(outputFileEncoding)
  73. {
  74. case eEncoding_ASCII:
  75. outputDescription += _T(" with ASCII encoding\r\n");
  76. break;
  77. case eEncoding_UCS2:
  78. outputDescription += _T(" with Unicode (UCS-2) encoding\r\n");
  79. break;
  80. case eEncoding_UTF8:
  81. outputDescription += _T(" with Unicode (UTF-8) encoding\r\n");
  82. break;
  83. }
  84. }
  85. break;
  86. case eOutput_Clipboard:
  87. default:
  88. outputDescription = _T("? Copy the file list to the clipboard\r\n");
  89. break;
  90. }
  91. m_editSummary.AppendText(outputDescription);
  92. }
  93. int CTestWizardCompletionPage::OnSetActive()
  94. {
  95. this->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
  96. // Don't remember any previous updates to the summary,
  97. // and just regenerate the whole summary
  98. this->UpdateSummary();
  99. // 0 = allow activate
  100. // -1 = go back to page that was active
  101. // page ID = jump to page
  102. return 0;
  103. }
  104. int CTestWizardCompletionPage::OnWizardBack()
  105. {
  106. // 0 = goto previous page
  107. // -1 = prevent page change
  108. // >0 = jump to page by dlg ID
  109. return m_pTestWizardInfo->FindPreviousPage(IDD);
  110. }
  111. INT_PTR CTestWizardCompletionPage::OnWizardFinish()
  112. {
  113. // We could either do the work here, or in the place that
  114. // called DoModal on our Sheet (which for this example is CTestWizard).
  115. // The advantage of doing the work here is that we can prevent
  116. // the finish, and tell the user to go back and correct something.
  117. // The advantage of doing it in the caller of DoModal is
  118. // that the wizard isn't visible while the work is being done.
  119. // For this example, we'll do the work here (or rather call back into
  120. // the info class to do the work), and prevent finish if something fails.
  121. CWaitCursor waitCursor;
  122. bool success = m_pTestWizardInfo->FinishWizard(m_hWnd);
  123. // FALSE = allow finish
  124. // TRUE = prevent finish
  125. // HWND = prevent finish and set focus to HWND (CommCtrl 5.80 only)
  126. return success ? FALSE : TRUE;
  127. }
  128. void CTestWizardCompletionPage::OnHelp()
  129. {
  130. m_pTestWizardInfo->ShowHelp(IDD);
  131. }