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.

156 lines
3.8 KiB

  1. //
  2. // BookEndPage.cpp
  3. //
  4. #include "stdafx.h"
  5. #include "BookEndPage.h"
  6. IMPLEMENT_DYNCREATE(CIISWizardBookEnd2, CIISWizardPage)
  7. CIISWizardBookEnd2::CIISWizardBookEnd2(
  8. HRESULT * phResult,
  9. UINT nIDWelcomeTxtSuccess,
  10. UINT nIDWelcomeTxtFailure,
  11. UINT nIDCaption,
  12. UINT * pnIDBodyTxtSuccess,
  13. CString * pBodyTxtSuccess,
  14. UINT * pnIDBodyTxtFailure,
  15. CString * pBodyTxtFailure,
  16. UINT nIDClickTxt,
  17. UINT nIDTemplate
  18. )
  19. : CIISWizardPage(nIDTemplate ? nIDTemplate : CIISWizardBookEnd2::IDD, nIDCaption),
  20. m_phResult(phResult),
  21. m_nIDWelcomeTxtSuccess(nIDWelcomeTxtSuccess),
  22. m_nIDWelcomeTxtFailure(nIDWelcomeTxtFailure),
  23. m_pnIDBodyTxtSuccess(pnIDBodyTxtSuccess),
  24. m_pBodyTxtSuccess(pBodyTxtSuccess),
  25. m_pnIDBodyTxtFailure(pnIDBodyTxtFailure),
  26. m_pBodyTxtFailure(pBodyTxtFailure),
  27. m_nIDClickTxt(nIDClickTxt),
  28. m_bTemplateAvailable(nIDTemplate != 0)
  29. {
  30. ASSERT(m_phResult != NULL); // Must know success/failure
  31. }
  32. CIISWizardBookEnd2::CIISWizardBookEnd2(
  33. UINT nIDTemplate,
  34. UINT nIDCaption,
  35. UINT * pnIDBodyTxt,
  36. CString * pBodyTxt,
  37. UINT nIDWelcomeTxt,
  38. UINT nIDClickTxt
  39. )
  40. : CIISWizardPage(nIDTemplate ? nIDTemplate : CIISWizardBookEnd2::IDD, nIDCaption),
  41. m_phResult(NULL),
  42. m_nIDWelcomeTxtSuccess(nIDWelcomeTxt),
  43. m_nIDWelcomeTxtFailure(USE_DEFAULT_CAPTION),
  44. m_pnIDBodyTxtSuccess(pnIDBodyTxt),
  45. m_pBodyTxtSuccess(pBodyTxt),
  46. m_pnIDBodyTxtFailure(NULL),
  47. m_pBodyTxtFailure(NULL),
  48. m_nIDClickTxt(nIDClickTxt),
  49. m_bTemplateAvailable(nIDTemplate != 0)
  50. {
  51. }
  52. BOOL
  53. CIISWizardBookEnd2::OnSetActive()
  54. {
  55. if (!m_strWelcome.IsEmpty())
  56. SetDlgItemText(IDC_STATIC_WZ_WELCOME, m_strWelcome);
  57. if (!m_strBody.IsEmpty())
  58. SetDlgItemText(IDC_STATIC_WZ_BODY, m_strBody);
  59. if (!m_strClick.IsEmpty())
  60. SetDlgItemText(IDC_STATIC_WZ_CLICK, m_strClick);
  61. SetWizardButtons(IsWelcomePage() ? PSWIZB_NEXT : PSWIZB_FINISH);
  62. return CIISWizardPage::OnSetActive();
  63. }
  64. //
  65. // Message Map
  66. //
  67. BEGIN_MESSAGE_MAP(CIISWizardBookEnd2, CIISWizardPage)
  68. //{{AFX_MSG_MAP(CIISWizardBookEnd)
  69. //}}AFX_MSG_MAP
  70. END_MESSAGE_MAP()
  71. BOOL
  72. CIISWizardBookEnd2::OnInitDialog()
  73. {
  74. CIISWizardPage::OnInitDialog();
  75. //
  76. // Make the "Click 'foo' to continue" message bold as well.
  77. //
  78. // ApplyFontToControls(this, GetBoldFont(), IDC_STATIC_WZ_CLICK, IDC_STATIC_WZ_CLICK);
  79. if (m_nIDClickTxt)
  80. {
  81. VERIFY(m_strClick.LoadString(m_nIDClickTxt));
  82. }
  83. if (IsWelcomePage())
  84. {
  85. if (m_nIDWelcomeTxtSuccess)
  86. {
  87. VERIFY(m_strWelcome.LoadString(m_nIDWelcomeTxtSuccess));
  88. }
  89. if (m_pBodyTxtSuccess != NULL)
  90. {
  91. m_strBody = *m_pBodyTxtSuccess;
  92. }
  93. else if (m_pnIDBodyTxtSuccess != NULL)
  94. {
  95. VERIFY(m_strBody.LoadString(*m_pnIDBodyTxtSuccess));
  96. }
  97. }
  98. else
  99. {
  100. CError err(*m_phResult);
  101. if (err.Succeeded())
  102. {
  103. if (m_nIDWelcomeTxtSuccess)
  104. {
  105. VERIFY(m_strWelcome.LoadString(m_nIDWelcomeTxtSuccess));
  106. }
  107. if (m_pBodyTxtSuccess != NULL && !m_pBodyTxtSuccess->IsEmpty())
  108. {
  109. m_strBody = *m_pBodyTxtSuccess;
  110. }
  111. else if (m_pnIDBodyTxtSuccess != NULL && *m_pnIDBodyTxtSuccess != USE_DEFAULT_CAPTION)
  112. {
  113. VERIFY(m_strBody.LoadString(*m_pnIDBodyTxtSuccess));
  114. }
  115. }
  116. else
  117. {
  118. if (m_nIDWelcomeTxtFailure)
  119. {
  120. VERIFY(m_strWelcome.LoadString(m_nIDWelcomeTxtFailure));
  121. }
  122. if (m_pBodyTxtFailure != NULL && !m_pBodyTxtFailure->IsEmpty())
  123. {
  124. m_strBody = *m_pBodyTxtFailure;
  125. }
  126. else if (m_pnIDBodyTxtFailure != NULL && *m_pnIDBodyTxtFailure != USE_DEFAULT_CAPTION)
  127. {
  128. VERIFY(m_strBody.LoadString(*m_pnIDBodyTxtFailure));
  129. }
  130. else
  131. {
  132. // Build body text string and expand error messages
  133. m_strBody = _T("%h");
  134. err.TextFromHRESULTExpand(m_strBody);
  135. }
  136. }
  137. }
  138. SetWizardButtons(IsWelcomePage() ? PSWIZB_NEXT : PSWIZB_FINISH);
  139. // We don't have documented way to disable Cancel button
  140. if (!IsWelcomePage())
  141. GetParent()->GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
  142. return TRUE;
  143. }