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.

197 lines
3.8 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*
  3. * COCPage.cpp
  4. *
  5. * A base class for an optional component wizard page.
  6. */
  7. #include "stdafx.h"
  8. #include "COCPage.h"
  9. /*
  10. * Class COCPageData
  11. */
  12. COCPageData::COCPageData ()
  13. {
  14. m_fPageActivated = FALSE;
  15. }
  16. BOOL COCPageData::WasPageActivated ()
  17. {
  18. return(m_fPageActivated);
  19. }
  20. COCPageData* COCPage::GetPageData () const
  21. {
  22. return(m_pPageData);
  23. }
  24. /*
  25. * Class COCPage
  26. */
  27. COCPage::COCPage (IN COCPageData *pPageData)
  28. {
  29. ASSERT(pPageData);
  30. m_hDlgWnd = NULL;
  31. m_pPageData = pPageData;
  32. }
  33. COCPage::~COCPage ()
  34. {
  35. }
  36. BOOL COCPage::Initialize ()
  37. {
  38. dwFlags = PSP_USECALLBACK;
  39. dwSize = sizeof(PROPSHEETPAGE);
  40. hInstance = GetInstance();
  41. lParam = (LPARAM)this;
  42. pfnCallback = PropSheetPageProc;
  43. pfnDlgProc = PropertyPageDlgProc;
  44. pszTemplate = MAKEINTRESOURCE(GetPageID());
  45. pszHeaderTitle = MAKEINTRESOURCE(GetHeaderTitleResource());
  46. if (pszHeaderTitle != NULL)
  47. {
  48. dwFlags |= PSP_USEHEADERTITLE;
  49. }
  50. pszHeaderSubTitle = MAKEINTRESOURCE(GetHeaderSubTitleResource());
  51. if (pszHeaderSubTitle != NULL)
  52. {
  53. dwFlags |= PSP_USEHEADERSUBTITLE;
  54. }
  55. return(pszTemplate != NULL ? TRUE : FALSE);
  56. }
  57. BOOL COCPage::OnNotify (IN HWND hDlgWnd, IN WPARAM /* wParam */, IN LPARAM lParam)
  58. {
  59. BOOL fApplied;
  60. NMHDR *pnmh = (LPNMHDR) lParam;
  61. switch(pnmh->code)
  62. {
  63. case PSN_SETACTIVE:
  64. GetPageData()->m_fPageActivated = CanShow();
  65. SetWindowLongPtr(hDlgWnd, DWLP_MSGRESULT, GetPageData()->m_fPageActivated ? 0 : -1);
  66. PropSheet_SetWizButtons(GetParent(hDlgWnd), PSWIZB_NEXT | PSWIZB_BACK);
  67. if (GetPageData()->m_fPageActivated)
  68. {
  69. GetHelperRoutines().ShowHideWizardPage(GetHelperRoutines().OcManagerContext,
  70. TRUE);
  71. OnActivation ();
  72. }
  73. break;
  74. case PSN_WIZNEXT:
  75. fApplied = ApplyChanges();
  76. SetWindowLongPtr(hDlgWnd, DWLP_MSGRESULT, fApplied ? 0 : -1);
  77. break;
  78. case PSN_WIZBACK:
  79. OnDeactivation();
  80. SetWindowLongPtr(hDlgWnd, DWLP_MSGRESULT, 0);
  81. break;
  82. default:
  83. return(FALSE);
  84. }
  85. return(TRUE);
  86. }
  87. UINT CALLBACK COCPage::PropSheetPageProc (IN HWND /* hWnd */, IN UINT uMsg, IN LPPROPSHEETPAGE pPsp)
  88. {
  89. COCPage* pThis;
  90. ASSERT(pPsp != NULL);
  91. pThis = reinterpret_cast<COCPage*>(pPsp->lParam);
  92. ASSERT(pThis != NULL);
  93. switch(uMsg)
  94. {
  95. case PSPCB_RELEASE:
  96. delete pThis;
  97. }
  98. return(1);
  99. }
  100. INT_PTR CALLBACK COCPage::PropertyPageDlgProc (IN HWND hDlgWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
  101. {
  102. COCPage* pDlg;
  103. if (uMsg == WM_INITDIALOG)
  104. {
  105. pDlg = reinterpret_cast<COCPage*>(LPPROPSHEETPAGE(lParam)->lParam);
  106. }
  107. else
  108. {
  109. pDlg = reinterpret_cast<COCPage*>(GetWindowLongPtr(hDlgWnd, DWLP_USER));
  110. }
  111. if (pDlg == NULL)
  112. {
  113. return(0);
  114. }
  115. switch(uMsg)
  116. {
  117. case WM_INITDIALOG:
  118. pDlg->SetDlgWnd(hDlgWnd);
  119. SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)pDlg);
  120. return(pDlg->OnInitDialog(hDlgWnd, wParam, lParam));
  121. case WM_NOTIFY:
  122. return(pDlg->OnNotify(hDlgWnd, wParam, lParam));
  123. case WM_COMMAND:
  124. return(pDlg->OnCommand(hDlgWnd, wParam, lParam));
  125. }
  126. return(0);
  127. }
  128. VOID COCPage::OnActivation ()
  129. {
  130. }
  131. BOOL COCPage::OnCommand (IN HWND /* hDlgWnd */, IN WPARAM /* wParam */, IN LPARAM /* lParam */)
  132. {
  133. return(TRUE);
  134. }
  135. VOID COCPage::OnDeactivation ()
  136. {
  137. }
  138. BOOL COCPage::OnInitDialog(IN HWND /* hDlgWnd */, IN WPARAM /* wParam */, IN LPARAM /* lParam */ )
  139. {
  140. return(TRUE);
  141. }
  142. BOOL COCPage::ApplyChanges ()
  143. {
  144. return(TRUE);
  145. }
  146. VOID COCPage::SetDlgWnd (IN HWND hDlgWnd)
  147. {
  148. m_hDlgWnd = hDlgWnd;
  149. }
  150. BOOL COCPage::VerifyChanges ()
  151. {
  152. return(TRUE);
  153. }