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.

2250 lines
66 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AtlBaseWiz.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CWizardWindow class.
  10. //
  11. // Author:
  12. // David Potter (davidp) December 2, 1997
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include <StrSafe.h>
  20. #include "AtlBaseWiz.h"
  21. #include "AtlBaseWizPage.h"
  22. #include "AtlExtDll.h"
  23. #include "StlUtils.h"
  24. #include "ExcOper.h"
  25. #include "AdmCommonRes.h"
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Local Type Definitions
  28. /////////////////////////////////////////////////////////////////////////////
  29. /////////////////////////////////////////////////////////////////////////////
  30. //
  31. // class CAltExtWizardGuardPage
  32. //
  33. // Purpose:
  34. // Guard page transferring control between the main wizard and the
  35. // alternate extension wizard.
  36. //
  37. /////////////////////////////////////////////////////////////////////////////
  38. template < class T >
  39. class CAltExtWizardGuardPage
  40. : public CExtensionWizardPageImpl< T >
  41. {
  42. typedef CAltExtWizardGuardPage< T > thisClass;
  43. typedef CExtensionWizardPageImpl< T > baseClass;
  44. public:
  45. //
  46. // Construction.
  47. //
  48. // Standard constructor
  49. CAltExtWizardGuardPage(
  50. DLGTEMPLATE * pdt
  51. )
  52. : m_pdt( pdt )
  53. {
  54. ATLASSERT( pdt != NULL );
  55. } //*** CAltExtWizardGuardPage()
  56. // Destructor
  57. ~CAltExtWizardGuardPage( void )
  58. {
  59. delete m_pdt;
  60. } //*** ~CAltExtWizardGuardPage()
  61. WIZARDPAGE_HEADERTITLEID( 0 )
  62. WIZARDPAGE_HEADERSUBTITLEID( 0 )
  63. enum { IDD = 0 };
  64. DECLARE_CLASS_NAME()
  65. // Return the help ID map
  66. static const DWORD * PidHelpMap( void )
  67. {
  68. static const DWORD s_aHelpIDs[] = { 0, 0 };
  69. return s_aHelpIDs;
  70. } //*** PidHelpMap()
  71. // Create the page
  72. DWORD ScCreatePage( void )
  73. {
  74. ATLASSERT( m_hpage == NULL );
  75. m_psp.dwFlags |= PSP_DLGINDIRECT;
  76. m_psp.pResource = m_pdt;
  77. m_hpage = CreatePropertySheetPage( &m_psp );
  78. if ( m_hpage == NULL )
  79. {
  80. return GetLastError();
  81. } // if: error creating the page
  82. return ERROR_SUCCESS;
  83. } //*** ScCreatePage()
  84. public:
  85. //
  86. // Message map.
  87. //
  88. BEGIN_MSG_MAP( thisClass )
  89. MESSAGE_HANDLER( WM_ACTIVATE, OnActivate )
  90. CHAIN_MSG_MAP( baseClass )
  91. END_MSG_MAP()
  92. //
  93. // Message handler functions.
  94. //
  95. // Handler for the WM_ACTIVATE message
  96. LRESULT OnActivate(
  97. UINT uMsg,
  98. WPARAM wParam,
  99. LPARAM lParam,
  100. BOOL & bHandled
  101. )
  102. {
  103. //
  104. // Don't allow us to be activated.
  105. //
  106. //WORD fActive = LOWORD( wParam );
  107. HWND hwndPrevious = (HWND) lParam;
  108. if ( wParam != WA_INACTIVE )
  109. {
  110. ::SetActiveWindow( hwndPrevious );
  111. }
  112. return 0;
  113. } //*** OnActivate()
  114. //
  115. // Message handler override functions.
  116. //
  117. protected:
  118. DLGTEMPLATE * m_pdt;
  119. }; //*** class CAltExtWizardGuardPage
  120. /////////////////////////////////////////////////////////////////////////////
  121. //
  122. // class CAltExtWizardPreLauncherPage
  123. //
  124. // Purpose:
  125. // Extension launcher wizard page used to display Wizard97 pages in
  126. // a non-Wizard97 sheet or vice-versa.
  127. //
  128. /////////////////////////////////////////////////////////////////////////////
  129. class CAltExtWizardPreLauncherPage
  130. : public CAltExtWizardGuardPage< CAltExtWizardPreLauncherPage >
  131. {
  132. typedef CAltExtWizardGuardPage< CAltExtWizardPreLauncherPage > baseClass;
  133. public:
  134. //
  135. // Construction.
  136. //
  137. // Standard constructor
  138. CAltExtWizardPreLauncherPage(
  139. DLGTEMPLATE * pdt
  140. )
  141. : baseClass( pdt )
  142. {
  143. } //*** CAltExtWizardPreLauncherPage()
  144. DECLARE_CLASS_NAME()
  145. public:
  146. //
  147. // Message map.
  148. //
  149. //BEGIN_MSG_MAP( CAltExtWizardPreLauncherPage )
  150. // CHAIN_MSG_MAP( baseClass )
  151. //END_MSG_MAP()
  152. //
  153. // Message handler functions.
  154. //
  155. //
  156. // Message handler overrides functions.
  157. //
  158. // Handler for PSN_SETACTIVE
  159. BOOL OnSetActive( void );
  160. }; //*** class CAltExtWizardPreLauncherPage
  161. /////////////////////////////////////////////////////////////////////////////
  162. //
  163. // class CAltExtWizardPostLauncherPage
  164. //
  165. // Purpose:
  166. // Page use to switch between the main wizard and the alternate
  167. // extension wizard when moving backwards.
  168. //
  169. /////////////////////////////////////////////////////////////////////////////
  170. class CAltExtWizardPostLauncherPage
  171. : public CAltExtWizardGuardPage< CAltExtWizardPostLauncherPage >
  172. {
  173. typedef CAltExtWizardGuardPage< CAltExtWizardPostLauncherPage > baseClass;
  174. public:
  175. //
  176. // Construction.
  177. //
  178. // Standard constructor
  179. CAltExtWizardPostLauncherPage(
  180. DLGTEMPLATE * pdt
  181. )
  182. : baseClass( pdt )
  183. {
  184. } //*** CAltExtWizardPostLauncherPage()
  185. DECLARE_CLASS_NAME()
  186. public:
  187. //
  188. // Message map.
  189. //
  190. //BEGIN_MSG_MAP( CAltExtWizardPostLauncherPage )
  191. // CHAIN_MSG_MAP( baseClass )
  192. //END_MSG_MAP()
  193. //
  194. // Message handler functions.
  195. //
  196. //
  197. // Message handler override functions.
  198. //
  199. // Handler for PSN_SETACTIVE
  200. BOOL OnSetActive( void );
  201. }; //*** class CAltExtWizardPostLauncherPage
  202. /////////////////////////////////////////////////////////////////////////////
  203. //
  204. // class CAltExtWizard
  205. //
  206. // Purpose:
  207. // Dummy wizard to host pages that are not of the same type as the main
  208. // wizard, e.g. non-Wizard97 pages in a Wizard97 wizard.
  209. //
  210. /////////////////////////////////////////////////////////////////////////////
  211. class CAltExtWizard : public CWizardImpl< CAltExtWizard >
  212. {
  213. typedef CWizardImpl< CAltExtWizard > baseClass;
  214. friend class CWizardWindow;
  215. friend class CAltExtWizardPreLauncherPage;
  216. friend class CAltExtWizardPostLauncherPage;
  217. friend class CAltExtWizardPrefixPage;
  218. friend class CAltExtWizardPostfixPage;
  219. public:
  220. //
  221. // Construction
  222. //
  223. // Standard constructor
  224. CAltExtWizard( void )
  225. : CWizardImpl< CAltExtWizard >( _T("") )
  226. , m_pwizMain( NULL )
  227. , m_bWindowMoved( FALSE )
  228. , m_bExitMsgLoop( FALSE )
  229. , m_nExitButton( 0 )
  230. {
  231. } //*** CExtensionAltWizard()
  232. // Initialize the sheet
  233. BOOL BInit( IN CWizardWindow * pwiz );
  234. public:
  235. //
  236. // Message map.
  237. //
  238. BEGIN_MSG_MAP( CAltExtWizard )
  239. COMMAND_HANDLER( IDCANCEL, BN_CLICKED, OnCancel )
  240. CHAIN_MSG_MAP( baseClass )
  241. END_MSG_MAP()
  242. //
  243. // Message handler functions.
  244. //
  245. // Handler for BN_CLICKED on the Cancel button
  246. LRESULT OnCancel(
  247. WORD wNotifyCode,
  248. WORD idCtrl,
  249. HWND hwndCtrl,
  250. BOOL & bHandled
  251. )
  252. {
  253. //
  254. // Notify the main wizard that the user pressed the cancel button.
  255. //
  256. ExitMessageLoop( PSBTN_CANCEL );
  257. bHandled = FALSE;
  258. return 0;
  259. } //*** OnCancel()
  260. //
  261. // Message handler override functions.
  262. //
  263. // Handler for the final message after WM_DESTROY
  264. void OnFinalMessage( HWND hWnd )
  265. {
  266. PwizMain()->DeleteAlternateWizard();
  267. } //*** OnFinalMessage()
  268. protected:
  269. CWizardWindow * m_pwizMain; // Pointer to the main wizard.
  270. BOOL m_bWindowMoved; // Indicates whether this window has been
  271. // repositioned over main wizard or not.
  272. BOOL m_bExitMsgLoop; // Indicates whether the message loop
  273. // should be exited or not.
  274. DWORD m_nExitButton; // Button to press after exiting.
  275. protected:
  276. // Return a pointer to the main wizard
  277. CWizardWindow * PwizMain( void ) { return m_pwizMain; }
  278. // Return whether the wizard has been moved yet
  279. BOOL BWindowMoved( void ) const { return m_bWindowMoved; }
  280. // Return whether the message loop should be exited or not
  281. BOOL BExitMessageLoop( void ) const { return m_bExitMsgLoop; }
  282. // Change whether the message loop should be exited or not
  283. void ExitMessageLoop( IN DWORD nButton )
  284. {
  285. ATLASSERT( (nButton == PSBTN_BACK) || (nButton == PSBTN_NEXT) || (nButton == PSBTN_CANCEL) );
  286. m_bExitMsgLoop = TRUE;
  287. m_nExitButton = nButton;
  288. } //*** ExitMessageLoop()
  289. // Return the button to press in the main wizard after exiting
  290. DWORD NExitButton( void ) const { return m_nExitButton; }
  291. protected:
  292. // Add the prefix page
  293. BOOL BAddPrefixPage( IN WORD cx, IN WORD cy );
  294. // Add the postfix page
  295. BOOL BAddPostfixPage( IN WORD cx, IN WORD cy );
  296. // Display the alternate wizard
  297. void DisplayAlternateWizard( void );
  298. // Display the main wizard
  299. void DisplayMainWizard( void );
  300. // Destroy the alternate extension wizard
  301. void DestroyAlternateWizard( void );
  302. // Message loop for the modeless wizard
  303. void MessageLoop( void );
  304. }; //*** class CAltExtWizard
  305. /////////////////////////////////////////////////////////////////////////////
  306. //
  307. // class CAltExtWizardPrefixPage
  308. //
  309. // Purpose:
  310. // Wizard page which precedes the first alternate page. This page
  311. // handles transferring control between the main wizard and the
  312. // alternate wizard.
  313. //
  314. /////////////////////////////////////////////////////////////////////////////
  315. class CAltExtWizardPrefixPage
  316. : public CAltExtWizardGuardPage< CAltExtWizardPrefixPage >
  317. {
  318. typedef CAltExtWizardGuardPage< CAltExtWizardPrefixPage > baseClass;
  319. public:
  320. //
  321. // Construction.
  322. //
  323. // Standard constructor
  324. CAltExtWizardPrefixPage(
  325. DLGTEMPLATE * pdt
  326. )
  327. : baseClass( pdt )
  328. {
  329. } //*** CAltExtWizardPrefixPage()
  330. DECLARE_CLASS_NAME()
  331. public:
  332. //
  333. // Message map.
  334. //
  335. //BEGIN_MSG_MAP( CAltExtWizardPrefixPage )
  336. // CHAIN_MSG_MAP( baseClass )
  337. //END_MSG_MAP()
  338. //
  339. // Message handler functions.
  340. //
  341. //
  342. // Message handler override functions.
  343. //
  344. // Handler for PSN_SETACTIVE
  345. BOOL OnSetActive( void );
  346. protected:
  347. // Return the alternate wizard object
  348. CAltExtWizard * PwizThis( void ) { return (CAltExtWizard *) Pwiz(); }
  349. }; //*** class CAltExtWizardPrefixPage
  350. /////////////////////////////////////////////////////////////////////////////
  351. //
  352. // class CAltExtWizardPostfixPage
  353. //
  354. // Purpose:
  355. // Wizard page which follows the last alternate page. This page
  356. // handles transferring control between the main wizard and the
  357. // alternate wizard.
  358. //
  359. /////////////////////////////////////////////////////////////////////////////
  360. class CAltExtWizardPostfixPage
  361. : public CAltExtWizardGuardPage< CAltExtWizardPostfixPage >
  362. {
  363. typedef CAltExtWizardGuardPage< CAltExtWizardPostfixPage > baseClass;
  364. public:
  365. //
  366. // Construction.
  367. //
  368. // Standard constructor
  369. CAltExtWizardPostfixPage(
  370. DLGTEMPLATE * pdt
  371. )
  372. : baseClass( pdt )
  373. {
  374. } //*** CAltExtWizardPostfixPage()
  375. DECLARE_CLASS_NAME()
  376. public:
  377. //
  378. // Message map.
  379. //
  380. //BEGIN_MSG_MAP( CAltExtWizardPostfixPage )
  381. // CHAIN_MSG_MAP( baseClass )
  382. //END_MSG_MAP()
  383. //
  384. // Message handler functions.
  385. //
  386. //
  387. // Message handler override functions.
  388. //
  389. // Handler for PSN_SETACTIVE
  390. BOOL OnSetActive( void );
  391. protected:
  392. // Return the alternate wizard object
  393. CAltExtWizard * PwizThis( void ) { return (CAltExtWizard *) Pwiz(); }
  394. }; //*** class CAltExtWizardPostfixPage
  395. //*************************************************************************//
  396. /////////////////////////////////////////////////////////////////////////////
  397. // class CWizardWindow
  398. /////////////////////////////////////////////////////////////////////////////
  399. /////////////////////////////////////////////////////////////////////////////
  400. //++
  401. //
  402. // CWizardWindow::~CWizardWindow
  403. //
  404. // Routine Description:
  405. // Destructor.
  406. //
  407. // Arguments:
  408. // None.
  409. //
  410. // Return Value:
  411. // None.
  412. //
  413. // Exceptions Thrown:
  414. // None.
  415. //
  416. //--
  417. /////////////////////////////////////////////////////////////////////////////
  418. CWizardWindow::~CWizardWindow( void )
  419. {
  420. //
  421. // Delete the alternate wizard, if it exists.
  422. //
  423. if ( (PwizAlternate() != NULL) && (PwizAlternate()->m_hWnd != NULL) )
  424. {
  425. reinterpret_cast< CAltExtWizard * >( PwizAlternate() )->DestroyAlternateWizard();
  426. } // if: alternate wizard exists
  427. //
  428. // Delete pages from the page list.
  429. //
  430. if ( m_plwpPages != NULL )
  431. {
  432. DeleteAllPtrListItems( m_plwpPages );
  433. delete m_plwpPages;
  434. } // if: page array has been allocated
  435. if ( m_plewpNormal != NULL )
  436. {
  437. DeleteAllPtrListItems( m_plewpNormal );
  438. delete m_plewpNormal;
  439. } // if: list already exists
  440. if ( m_plewpAlternate != NULL )
  441. {
  442. DeleteAllPtrListItems( m_plewpAlternate );
  443. delete m_plewpAlternate;
  444. } // if: list already exists
  445. } //*** CWizardWindow::~CWizardWindow()
  446. /////////////////////////////////////////////////////////////////////////////
  447. //++
  448. //
  449. // CWizardWindow::BAddPage
  450. //
  451. // Routine Description:
  452. // Add a page to the page list. If it is the first page, it won't have
  453. // a BACK button. If it isn't the first page, the last page will have
  454. // its FINISH button changed to a NEXT button and this page will have
  455. // both a FINISH button and a BACK button.
  456. //
  457. // Arguments:
  458. // pwp [IN] Wizard page to add.
  459. //
  460. // Return Value:
  461. // TRUE Page added successfully.
  462. // FALSE Error adding page.
  463. //
  464. //--
  465. /////////////////////////////////////////////////////////////////////////////
  466. BOOL CWizardWindow::BAddPage( IN CWizardPageWindow * pwp )
  467. {
  468. ATLASSERT( pwp != NULL );
  469. // Make sure specified page hasn't already been added.
  470. ATLASSERT( (m_plwpPages == NULL)
  471. || (std::find( PlwpPages()->begin(), PlwpPages()->end(), pwp ) == PlwpPages()->end()) );
  472. BOOL bSuccess = FALSE;
  473. ULONG fWizardButtons = PSWIZB_FINISH;
  474. ULONG fPrevWizardButtons;
  475. // Loop to avoid goto's.
  476. do
  477. {
  478. //
  479. // Allocate the page list if it doesn't exist yet.
  480. //
  481. if ( m_plwpPages == NULL )
  482. {
  483. m_plwpPages = new CWizardPageList;
  484. if ( m_plwpPages == NULL )
  485. {
  486. CNTException nte(
  487. static_cast< DWORD >( E_OUTOFMEMORY ),
  488. ADMC_IDS_ADD_FIRST_PAGE_TO_PROP_SHEET_ERROR,
  489. NULL, // pszOperArg1
  490. NULL, // pszOperArg2
  491. FALSE // bAutoDelete
  492. );
  493. nte.ReportError();
  494. break;
  495. } // if: error allocating page list
  496. } // if: no page array yet
  497. //
  498. // If this is not the first page in the list, set the previous
  499. // page's wizard buttons to have a NEXT button instead of a
  500. // FINISH button and set this page to have a BACK button.
  501. //
  502. if ( PlwpPages()->size() > 0 )
  503. {
  504. //
  505. // Get the current last page.
  506. //
  507. CWizardPageList::iterator itFirst = PlwpPages()->begin();
  508. CWizardPageList::iterator itLast = PlwpPages()->end();
  509. ATLASSERT( itFirst != itLast );
  510. CWizardPageWindow * pwpPrev = *(--PlwpPages()->end());
  511. ATLASSERT( pwpPrev != NULL );
  512. //
  513. // Set the wizard buttons on that page.
  514. //
  515. fPrevWizardButtons = pwpPrev->FWizardButtons();
  516. fPrevWizardButtons &= ~PSWIZB_FINISH;
  517. fPrevWizardButtons |= PSWIZB_NEXT;
  518. pwpPrev->SetDefaultWizardButtons( fPrevWizardButtons );
  519. fWizardButtons |= PSWIZB_BACK;
  520. } // if: not the first page added
  521. pwp->SetDefaultWizardButtons( fWizardButtons );
  522. //
  523. // Insert the page at the end of the list.
  524. //
  525. PlwpPages()->insert( PlwpPages()->end(), pwp );
  526. //
  527. // Add the page to the sheet. If the sheet hasn't been created yet,
  528. // add it to the sheet header list. If the sheet has been created,
  529. // add it to the sheet dynamically. Note that the page must not be a
  530. // static page.
  531. //
  532. if ( m_hWnd == NULL )
  533. {
  534. //
  535. // If this is a dynamic page, add it using its hpage. Otherwise
  536. // it must be a static page. Add it by its property sheet page header.
  537. //
  538. CDynamicWizardPageWindow * pdwp = dynamic_cast< CDynamicWizardPageWindow * >( pwp );
  539. if ( pdwp != NULL )
  540. {
  541. if ( pdwp->Hpage() != NULL )
  542. {
  543. ATLASSERT( ! pdwp->BPageAddedToSheet() );
  544. bSuccess = BAddPageToSheetHeader( pdwp->Hpage() );
  545. if ( ! bSuccess )
  546. {
  547. CNTException nte(
  548. GetLastError(),
  549. ADMC_IDS_ADD_PAGE_TO_WIZARD_ERROR,
  550. NULL,
  551. NULL,
  552. FALSE
  553. );
  554. nte.ReportError();
  555. break;
  556. } // if: error adding the page to the sheet header
  557. pdwp->SetPageAdded( TRUE );
  558. } // if: page already created
  559. } // if: dynamic page
  560. else
  561. {
  562. // Must be static page
  563. ATLASSERT( dynamic_cast< CStaticWizardPageWindow * >( pwp ) != NULL );
  564. //
  565. // Initialize the page.
  566. //
  567. bSuccess = pwp->BInit( this );
  568. if ( ! bSuccess )
  569. {
  570. break;
  571. } // if: error initializing the page
  572. //
  573. // Add the page.
  574. //
  575. bSuccess = AddPage( pwp->Ppsp() );
  576. if ( ! bSuccess )
  577. {
  578. CNTException nte(
  579. GetLastError(),
  580. ADMC_IDS_ADD_PAGE_TO_WIZARD_ERROR,
  581. NULL,
  582. NULL,
  583. FALSE
  584. );
  585. nte.ReportError();
  586. break;
  587. } // if: error adding the page
  588. } // else: not dynamic page
  589. } // if: sheet has been created
  590. else
  591. {
  592. // Can't be static page. Must be dynamic page.
  593. ATLASSERT( dynamic_cast< CStaticWizardPageWindow * >( pwp ) == NULL );
  594. CDynamicWizardPageWindow * pdwp = dynamic_cast< CDynamicWizardPageWindow * >( pwp );
  595. ATLASSERT( pdwp != NULL );
  596. AddPage( pdwp->Hpage() );
  597. pdwp->SetPageAdded( TRUE );
  598. } // else: sheet already created
  599. //
  600. // If we get to here we are successfully.
  601. //
  602. bSuccess = TRUE;
  603. } while ( 0 );
  604. return bSuccess;
  605. } //*** CWizardWindow::BAddPage()
  606. /////////////////////////////////////////////////////////////////////////////
  607. //++
  608. //
  609. // CWizardWindow::OnSheetInitialized
  610. //
  611. // Routine Description:
  612. // Handler for PSCB_INITIALIZED.
  613. // Add pages that haven't been added yet, which will only be dynamic
  614. // pages.
  615. //
  616. // Arguments:
  617. // None.
  618. //
  619. // Return Value:
  620. // None.
  621. //
  622. // Exceptions Thrown:
  623. // None.
  624. //
  625. //--
  626. /////////////////////////////////////////////////////////////////////////////
  627. void CWizardWindow::OnSheetInitialized( void )
  628. {
  629. //
  630. // Remove the system menu.
  631. //
  632. ModifyStyle( WS_SYSMENU, 0 );
  633. //
  634. // Add dynamic pages, including extension pages, if not added yet.
  635. //
  636. {
  637. //
  638. // Get pointers to beginning and end of list.
  639. //
  640. CWizardPageList::iterator itCurrent = PlwpPages()->begin();
  641. CWizardPageList::iterator itLast = PlwpPages()->end();
  642. //
  643. // Loop through the list and add each dynamic page.
  644. //
  645. for ( ; itCurrent != itLast ; itCurrent++ )
  646. {
  647. CDynamicWizardPageWindow * pdwp = dynamic_cast< CDynamicWizardPageWindow * >( *itCurrent );
  648. if ( pdwp != NULL )
  649. {
  650. if ( ! pdwp->BPageAddedToSheet() && (pdwp->Hpage() != NULL) )
  651. {
  652. AddPage( pdwp->Hpage() );
  653. pdwp->SetPageAdded( TRUE );
  654. } // if: page not added yet and page has already been created
  655. } // if: dynamic page found
  656. } // for: each item in the list
  657. } // Add dynamic pages, including extension pages
  658. //
  659. // Call the base class method.
  660. //
  661. CBaseSheetWindow::OnSheetInitialized();
  662. } //*** CWizardWindow::OnSheetInitialized()
  663. /////////////////////////////////////////////////////////////////////////////
  664. //++
  665. //
  666. // CWizardWindow::SetNextPage
  667. //
  668. // Routine Description:
  669. // Set the next page to be displayed.
  670. //
  671. // Arguments:
  672. // pwCurrentPage [IN] Current page whose next page is to be enabled.
  673. // pszNextPage [IN] Page ID.
  674. //
  675. // Return Value:
  676. // pwizpg
  677. //
  678. //--
  679. /////////////////////////////////////////////////////////////////////////////
  680. void CWizardWindow::SetNextPage(
  681. IN CWizardPageWindow * pwCurrentPage,
  682. IN LPCTSTR pszNextPage
  683. )
  684. {
  685. ATLASSERT( pwCurrentPage != NULL );
  686. ATLASSERT( pszNextPage != NULL );
  687. BOOL bFoundCurrent = FALSE;
  688. CWizardPageWindow * pwPage;
  689. CWizardPageList::iterator itCurrent = PlwpPages()->begin();
  690. CWizardPageList::iterator itLast = PlwpPages()->end();
  691. //
  692. // Skip pages until the current page is found.
  693. //
  694. for ( ; itCurrent != itLast ; itCurrent++ )
  695. {
  696. pwPage = *itCurrent;
  697. if ( pwPage == pwCurrentPage )
  698. {
  699. bFoundCurrent = TRUE;
  700. break;
  701. } // if: found the current page
  702. } // for: each page in the list
  703. ATLASSERT( bFoundCurrent );
  704. //
  705. // Disable all succeeding pages until the desired next page
  706. // is found. Enable that page and then exit.
  707. //
  708. for ( itCurrent++ ; itCurrent != itLast ; itCurrent++ )
  709. {
  710. if ( (*itCurrent)->Ppsp()->pszTemplate == pszNextPage )
  711. {
  712. (*itCurrent)->EnablePage( TRUE );
  713. break;
  714. } // if: found the page
  715. (*itCurrent)->EnablePage( FALSE );
  716. } // for: each page in the list
  717. ATLASSERT( itCurrent != itLast );
  718. } //*** CWizardWindow::SetNextPage( pszNextPage )
  719. /////////////////////////////////////////////////////////////////////////////
  720. //++
  721. //
  722. // CWizardWindow::AddExtensionPages
  723. //
  724. // Routine Description:
  725. // Add extension pages to the sheet.
  726. //
  727. // Arguments:
  728. // hfont [IN] Font to use for the extension pages.
  729. // hicon [IN] Icon to use for the extension pages.
  730. //
  731. // Return Value:
  732. // None.
  733. //
  734. //--
  735. /////////////////////////////////////////////////////////////////////////////
  736. void CWizardWindow::AddExtensionPages( IN HFONT hfont, IN HICON hicon )
  737. {
  738. ATLASSERT( PcoObjectToExtend() != NULL );
  739. //
  740. // Add extension pages if there any extensions.
  741. //
  742. if ( (PcoObjectToExtend()->PlstrAdminExtensions() != NULL)
  743. && (PcoObjectToExtend()->PlstrAdminExtensions()->size() > 0) )
  744. {
  745. //
  746. // Get the currently selected page so we can reset it when we're done.
  747. //
  748. CTabCtrl tabc( GetTabControl() );
  749. int nCurPage = tabc.GetCurSel();
  750. //
  751. // Prepare to add extension pages.
  752. //
  753. CDynamicWizardPageList ldwp;
  754. PrepareToAddExtensionPages( ldwp );
  755. //
  756. // If no extensions object has been created yet, create it now.
  757. //
  758. if ( Pext() == NULL )
  759. {
  760. m_pext = new CCluAdmExtensions;
  761. ATLASSERT( m_pext != NULL );
  762. if ( m_pext == NULL )
  763. {
  764. return;
  765. } // if: error allocating the extension object
  766. } // if: no extensions list yet
  767. //
  768. // Enclose the loading of the extension in a try/catch block so
  769. // that a failure to load the extension won't prevent all pages
  770. // from being displayed.
  771. //
  772. try
  773. {
  774. if ( BWizard97() )
  775. {
  776. Pext()->CreateWizard97Pages(
  777. this,
  778. *PcoObjectToExtend()->PlstrAdminExtensions(),
  779. PcoObjectToExtend(),
  780. hfont,
  781. hicon
  782. );
  783. } // if: Wizard97 wizard
  784. else
  785. {
  786. Pext()->CreateWizardPages(
  787. this,
  788. *PcoObjectToExtend()->PlstrAdminExtensions(),
  789. PcoObjectToExtend(),
  790. hfont,
  791. hicon
  792. );
  793. } // else: non-Wizard97 wizard
  794. } // try
  795. catch (...)
  796. {
  797. } // catch: anything
  798. //
  799. // Complete the process of adding extension pages.
  800. //
  801. CompleteAddingExtensionPages( ldwp );
  802. //
  803. // Restore the current selection.
  804. // This has to be done because sometimes the above process causes
  805. // the current page to be set to the last page added, which prevents
  806. // the next page from being displayed.
  807. //
  808. SetActivePage( nCurPage );
  809. } // if: object has extensions
  810. else
  811. {
  812. //
  813. // Remove extension pages.
  814. //
  815. RemoveAllExtensionPages();
  816. } // else: object doesn't have extensions
  817. } //*** CWizardWindow::AddExtensionPages()
  818. /////////////////////////////////////////////////////////////////////////////
  819. //++
  820. //
  821. // CWizardWindow::PrepareToAddExtensionPages
  822. //
  823. // Routine Description:
  824. // Prepare to add extension pages by deleting existing extension
  825. // pages and removing dynamic pages.
  826. //
  827. // Arguments:
  828. // rldwp [IN OUT] List of dynamic wizard pages.
  829. //
  830. // Return Value:
  831. // None.
  832. //
  833. //--
  834. /////////////////////////////////////////////////////////////////////////////
  835. void CWizardWindow::PrepareToAddExtensionPages(
  836. IN OUT CDynamicWizardPageList & rldwp
  837. )
  838. {
  839. //
  840. // Delete all extension pages from this wizard. This also
  841. // includes destroy the alternate wizard if it exists.
  842. //
  843. RemoveAllExtensionPages();
  844. //
  845. // Delete the lists of extension pages and make sure the lists exist.
  846. //
  847. if ( PlewpNormal() != NULL )
  848. {
  849. DeleteAllPtrListItems( PlewpNormal() );
  850. } // if: list already exists
  851. else
  852. {
  853. m_plewpNormal = new CExtensionWizardPageList;
  854. if ( m_plewpNormal == NULL )
  855. {
  856. return;
  857. } // if: error allocating the page list
  858. } // else: list doesn't exist yet
  859. if ( PlewpAlternate() != NULL )
  860. {
  861. DeleteAllPtrListItems( PlewpAlternate() );
  862. } // if: list already exists
  863. else
  864. {
  865. m_plewpAlternate = new CExtensionWizardPageList;
  866. if ( m_plewpAlternate == NULL )
  867. {
  868. return;
  869. } // if: error allocating the page list
  870. } // else: list doesn't exist yet
  871. //
  872. // Move all dynamic pages to the temporary list.
  873. //
  874. ATLASSERT( rldwp.size() == 0 );
  875. MovePtrListItems< CWizardPageWindow *, CDynamicWizardPageWindow * >( PlwpPages(), &rldwp );
  876. //
  877. // Remove all pages in the temporary list from the wizard.
  878. //
  879. {
  880. CDynamicWizardPageList::iterator itCurrent;
  881. CDynamicWizardPageList::iterator itLast;
  882. itCurrent = rldwp.begin();
  883. itLast = rldwp.end();
  884. for ( ; itCurrent != itLast ; itCurrent++ )
  885. {
  886. CDynamicWizardPageWindow * pdwp = *itCurrent;
  887. ATLASSERT( pdwp != NULL );
  888. if ( pdwp->Hpage() != NULL )
  889. {
  890. RemovePage( pdwp->Hpage() );
  891. pdwp->SetPageAdded( FALSE );
  892. } // if: page already created
  893. } // for: each page in the list
  894. } // Remove dynamic pages
  895. } //*** CWizardWindow::PrepareToAddExtensionPages()
  896. /////////////////////////////////////////////////////////////////////////////
  897. //++
  898. //
  899. // CWizardWindow::HrAddExtensionPage
  900. //
  901. // Routine Description:
  902. // Add an extension page.
  903. //
  904. // Arguments:
  905. // ppage [IN] Page to be added.
  906. //
  907. // Return Value:
  908. // S_OK Page added successfully.
  909. // S_FALSE Page not added.
  910. //
  911. //--
  912. /////////////////////////////////////////////////////////////////////////////
  913. HRESULT CWizardWindow::HrAddExtensionPage( IN CBasePageWindow * ppage )
  914. {
  915. ATLASSERT( ppage != NULL );
  916. HRESULT hr = S_OK;
  917. //
  918. // Make sure this is an extension wizard page object.
  919. //
  920. CExtensionWizardPageWindow * pewp = dynamic_cast< CExtensionWizardPageWindow * >( ppage );
  921. ATLASSERT( pewp != NULL );
  922. if ( (ppage == NULL)
  923. || (pewp == NULL ) )
  924. {
  925. return S_FALSE;
  926. } // if: invalid arguments
  927. //
  928. // If the page is not the same as the type of wizard, add it to the
  929. // alternate list of extension pages and indicate we need a dummy sheet.
  930. // Otherwise, add it to the standard list of extension pages.
  931. //
  932. CExtensionWizard97PageWindow * pew97p = dynamic_cast< CExtensionWizard97PageWindow * >( ppage );
  933. if ( ((pew97p != NULL) && ! BWizard97())
  934. || ((pew97p == NULL) && BWizard97()) )
  935. {
  936. PlewpAlternate()->insert( PlewpAlternate()->end(), pewp );
  937. } // if: trying to add the wrong type of page
  938. else
  939. {
  940. PlewpNormal()->insert( PlewpNormal()->end(), pewp );
  941. } // else: adding page of matching type
  942. return hr;
  943. } //*** CWizardWindow::HrAddExtensionPage()
  944. /////////////////////////////////////////////////////////////////////////////
  945. //++
  946. //
  947. // CWizardWindow::CompleteAddingExtensionPages
  948. //
  949. // Routine Description:
  950. // Complete the process of adding extension pages to the wizard by
  951. // re-adding dynamic pages.
  952. //
  953. // Arguments:
  954. // rldwp [IN OUT] List of dynamic wizard pages.
  955. //
  956. // Return Value:
  957. // None.
  958. //
  959. //--
  960. /////////////////////////////////////////////////////////////////////////////
  961. void CWizardWindow::CompleteAddingExtensionPages(
  962. IN OUT CDynamicWizardPageList & rldwp
  963. )
  964. {
  965. //
  966. // If there are any normal pages, add them here.
  967. // There will be normal pages if pages of the same type as the wizard
  968. // were added.
  969. //
  970. if ( PlewpNormal()->size() > 0 )
  971. {
  972. //
  973. // Add pages to the sheet.
  974. //
  975. if ( m_hWnd != NULL )
  976. {
  977. CExtensionWizardPageList::iterator itCurrent = PlewpNormal()->begin();
  978. CExtensionWizardPageList::iterator itLast = PlewpNormal()->end();
  979. for ( ; itCurrent != itLast ; itCurrent++ )
  980. {
  981. CExtensionWizardPageWindow * pewp = *itCurrent;
  982. ATLASSERT( pewp != NULL );
  983. BAddPage( pewp );
  984. } // for: each page in the list
  985. } // if: sheet is currently being displayed
  986. } // if: there are normal pages
  987. //
  988. // If there are any alternate pages, add a pre-extension launcher page
  989. // and a post-extension launcher page. The pre-extension launcher page
  990. // will display an alternate wizard of the appropriate type and hide the
  991. // main wizard before displaying these pages. After the final page it
  992. // will display the original sheet and hide the other sheet. The
  993. // post-extension launcher page is used to transition between the main
  994. // wizard and the alternate wizard when moving backwards into the
  995. // alternate wizard.
  996. //
  997. if ( PlewpAlternate()->size() > 0 )
  998. {
  999. DLGTEMPLATE * pdt = NULL;
  1000. CAltExtWizardPreLauncherPage * pelwpPre = NULL;
  1001. CAltExtWizardPostLauncherPage * pelwpPost = NULL;
  1002. // Loop to avoid goto's
  1003. do
  1004. {
  1005. //
  1006. // Add the pre-extension launcher page.
  1007. //
  1008. {
  1009. //
  1010. // Create the dialog template.
  1011. //
  1012. pdt = PdtCreateDummyPageDialogTemplate( 10, 10 );
  1013. ATLASSERT( pdt != NULL );
  1014. if ( pdt == NULL )
  1015. {
  1016. break;
  1017. } // if: error creating the dialog template
  1018. //
  1019. // Allocate and initialize the launcher page.
  1020. //
  1021. pelwpPre = new CAltExtWizardPreLauncherPage( pdt );
  1022. ATLASSERT( pelwpPre != NULL );
  1023. if ( pelwpPre == NULL )
  1024. {
  1025. break;
  1026. } // if: error allocating the page
  1027. pdt = NULL;
  1028. if ( ! pelwpPre->BInit( this ) )
  1029. {
  1030. break;
  1031. } // if: error initializing the page
  1032. //
  1033. // Create the launcher page.
  1034. //
  1035. DWORD sc = pelwpPre->ScCreatePage();
  1036. if ( sc != ERROR_SUCCESS )
  1037. {
  1038. CNTException nte(
  1039. sc,
  1040. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1041. NULL,
  1042. NULL,
  1043. FALSE
  1044. );
  1045. nte.ReportError();
  1046. break;
  1047. } // if: error creating the page
  1048. //
  1049. // Add the launcher page to the wizard.
  1050. //
  1051. BAddPage( pelwpPre );
  1052. pelwpPre = NULL;
  1053. } // Add the pre-extension launcher page
  1054. //
  1055. // Add the post-extension launcher page
  1056. //
  1057. {
  1058. //
  1059. // Create the dialog template.
  1060. //
  1061. pdt = PdtCreateDummyPageDialogTemplate( 10, 10 );
  1062. ATLASSERT( pdt != NULL );
  1063. if ( pdt == NULL )
  1064. {
  1065. break;
  1066. } // if: error creating the dialog template
  1067. //
  1068. // Allocate and initialize the launcher page.
  1069. //
  1070. pelwpPost = new CAltExtWizardPostLauncherPage( pdt );
  1071. ATLASSERT( pelwpPost != NULL );
  1072. if ( pelwpPost == NULL )
  1073. {
  1074. break;
  1075. } // if: error allocating page
  1076. pdt = NULL;
  1077. if ( ! pelwpPost->BInit( this ) )
  1078. {
  1079. break;
  1080. } // if: error initializing the page
  1081. //
  1082. // Create the launcher page.
  1083. //
  1084. DWORD sc = pelwpPost->ScCreatePage();
  1085. if ( sc != ERROR_SUCCESS )
  1086. {
  1087. CNTException nte(
  1088. sc,
  1089. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1090. NULL,
  1091. NULL,
  1092. FALSE
  1093. );
  1094. nte.ReportError();
  1095. break;
  1096. } // if: error creating the page
  1097. //
  1098. // Add the launcher page to the wizard.
  1099. //
  1100. BAddPage( pelwpPost );
  1101. pelwpPost = NULL;
  1102. } // Add the post-extension launcher page
  1103. } while ( 0 );
  1104. //
  1105. // Cleanup;
  1106. //
  1107. delete pelwpPre;
  1108. delete pelwpPost;
  1109. delete pdt;
  1110. } // if: there are alternate pages
  1111. //
  1112. // Move all pages from the temporary list to the real list and
  1113. // add them to the end of the wizard.
  1114. //
  1115. CDynamicWizardPageList::iterator itCurrent = rldwp.begin();
  1116. CDynamicWizardPageList::iterator itLast = rldwp.end();
  1117. while ( itCurrent != itLast )
  1118. {
  1119. CDynamicWizardPageWindow * pdwp = *itCurrent;
  1120. ATLASSERT( pdwp != NULL );
  1121. //
  1122. // Create the page.
  1123. //
  1124. DWORD sc = pdwp->ScCreatePage();
  1125. if ( sc != ERROR_SUCCESS )
  1126. {
  1127. CNTException nte(
  1128. sc,
  1129. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1130. NULL,
  1131. NULL,
  1132. FALSE
  1133. );
  1134. delete pdwp;
  1135. itCurrent = rldwp.erase( itCurrent );
  1136. continue;
  1137. } // if: error creating the page
  1138. //
  1139. // Add the page to the wizard.
  1140. // This adds it to the real page list as well.
  1141. //
  1142. BAddPage( pdwp );
  1143. //
  1144. // Remove the page from the temporary list.
  1145. //
  1146. itCurrent = rldwp.erase( itCurrent );
  1147. } // while: not at last page
  1148. } //*** CWizardWindow::CompleteAddingExtensionPages()
  1149. /////////////////////////////////////////////////////////////////////////////
  1150. //++
  1151. //
  1152. // CWizardWindow::RemoveAllExtensionPages
  1153. //
  1154. // Routine Description:
  1155. // Remove all extension pages from the wizard.
  1156. //
  1157. // Arguments:
  1158. // None.
  1159. //
  1160. // Return Value:
  1161. // None.
  1162. //
  1163. //--
  1164. /////////////////////////////////////////////////////////////////////////////
  1165. void CWizardWindow::RemoveAllExtensionPages( void )
  1166. {
  1167. //
  1168. // Delete the alternate extension wizard.
  1169. //
  1170. if ( PwizAlternate() != NULL )
  1171. {
  1172. reinterpret_cast< CAltExtWizard * >( PwizAlternate() )->DestroyAlternateWizard();
  1173. } // if: alternate wizard being displayed
  1174. //
  1175. // Remove the extension pages.
  1176. //
  1177. CExtensionWizardPageList lewp;
  1178. MovePtrListItems< CWizardPageWindow *, CExtensionWizardPageWindow * >( PlwpPages(), &lewp );
  1179. CExtensionWizardPageList::iterator itCurrent = lewp.begin();
  1180. CExtensionWizardPageList::iterator itLast = lewp.end();
  1181. for ( ; itCurrent != itLast ; itCurrent++ )
  1182. {
  1183. CExtensionWizardPageWindow * pewp = *itCurrent;
  1184. ATLASSERT( pewp != NULL );
  1185. if ( pewp->Hpage() != NULL )
  1186. {
  1187. RemovePage( pewp->Hpage() );
  1188. pewp->SetPageAdded( FALSE );
  1189. } // if: page already created
  1190. } // for: each page in the list
  1191. DeleteAllPtrListItems( &lewp );
  1192. } //*** CWizardWindow::RemoveAllExtensionPages()
  1193. //*************************************************************************//
  1194. ////////////////////////////////////////////////////////////////////////////
  1195. // class CAltExtWizardPreLauncherPage
  1196. /////////////////////////////////////////////////////////////////////////////
  1197. /////////////////////////////////////////////////////////////////////////////
  1198. //++
  1199. //
  1200. // CAltExtWizardPreLauncherPage::OnSetActive
  1201. //
  1202. // Routine Description:
  1203. // Handler for PSN_SETACTIVE.
  1204. // This page will be displayed if there are pages that are not of the
  1205. // same type as the wizard (e.g. non-Wizard97 pages in a Wizard97
  1206. // wizard).
  1207. //
  1208. // Arguments:
  1209. // None.
  1210. //
  1211. // Return Value:
  1212. // TRUE Page activated successfully.
  1213. // FALSE Error activating page.
  1214. //
  1215. //--
  1216. /////////////////////////////////////////////////////////////////////////////
  1217. BOOL CAltExtWizardPreLauncherPage::OnSetActive( void )
  1218. {
  1219. CAltExtWizard * pwizAlt;
  1220. //
  1221. // When moving forward, create the alternate extension wizard and return
  1222. // TRUE so that the main wizard will wait here. The alternate wizard
  1223. // will cause the proper button to be pressed so we can do the proper
  1224. // thing when we're done.
  1225. //
  1226. // When moving backward, just return FALSE so we won't be displayed.
  1227. //
  1228. //
  1229. // Create the alternate wizard if moving forward.
  1230. //
  1231. if ( Pwiz()->BNextPressed() )
  1232. {
  1233. // We could have got here by pressing 'Back' on the alternate wizard,
  1234. // and then pressing 'Next' on the normal wizard. So, first check if
  1235. // the alternate wizard has already been created.
  1236. if ( Pwiz()->PwizAlternate() == NULL )
  1237. {
  1238. //
  1239. // Create the alternate extension wizard.
  1240. // It is expected that the wizard doesn't exist yet and that there are
  1241. // alternate extension pages to be displayed.
  1242. //
  1243. ATLASSERT( Pwiz()->PlewpAlternate()->size() > 0 );
  1244. pwizAlt = new CAltExtWizard;
  1245. ATLASSERT( pwizAlt != NULL );
  1246. if ( pwizAlt == NULL )
  1247. {
  1248. return FALSE;
  1249. } // if: error allocating the alternate wizard
  1250. Pwiz()->SetAlternateWizard( pwizAlt );
  1251. //
  1252. // Initialize the alternate extension wizard.
  1253. //
  1254. if ( pwizAlt->BInit( Pwiz() ) )
  1255. {
  1256. //
  1257. // Display the alternate extension wizard.
  1258. // The alternate extension wizard is being displayed as a modeless
  1259. // wizard so that when the user presses the Next button in the
  1260. // wizard and then presses the Back button on the next main wizard
  1261. // page we need the wizard to still exist.
  1262. //
  1263. pwizAlt->Create( GetActiveWindow() );
  1264. //
  1265. // Execute the alternate wizard message loop.
  1266. // This required so that tabs and accelerator keys will work.
  1267. //
  1268. pwizAlt->MessageLoop();
  1269. } // if: wizard initialized successfully
  1270. return TRUE;
  1271. } // if: alternate wizard does not exist
  1272. else
  1273. {
  1274. //
  1275. // Display the existing alternate wizard.
  1276. // Press the alternate wizard's Next button because it is waiting at
  1277. // the prefix page.
  1278. //
  1279. pwizAlt = reinterpret_cast< CAltExtWizard * >( Pwiz()->PwizAlternate() );
  1280. pwizAlt->PressButton( PSBTN_NEXT );
  1281. pwizAlt->DisplayAlternateWizard();
  1282. //
  1283. // Execute the alternate wizard message loop.
  1284. // This required so that tabs and accelerator keys will work.
  1285. //
  1286. pwizAlt->MessageLoop();
  1287. return TRUE;
  1288. } // else: alternate wizard exists already
  1289. } // if: next button pressed
  1290. else
  1291. {
  1292. ATLASSERT( Pwiz()->BBackPressed() );
  1293. return FALSE;
  1294. } // else: back button pressed
  1295. } //*** CAltExtWizardPreLauncherPage::OnSetActive()
  1296. //*************************************************************************//
  1297. ////////////////////////////////////////////////////////////////////////////
  1298. // class CAltExtWizardPostLauncherPage
  1299. /////////////////////////////////////////////////////////////////////////////
  1300. /////////////////////////////////////////////////////////////////////////////
  1301. //++
  1302. //
  1303. // CAltExtWizardPostLauncherPage::OnSetActive
  1304. //
  1305. // Routine Description:
  1306. // Handler for PSN_SETACTIVE.
  1307. // This page will be displayed if there are pages that are not of the
  1308. // same type as the wizard (e.g. non-Wizard97 pages in a Wizard97
  1309. // wizard).
  1310. //
  1311. // Arguments:
  1312. // None.
  1313. //
  1314. // Return Value:
  1315. // TRUE Page activated successfully.
  1316. // FALSE Error activating page.
  1317. //
  1318. //--
  1319. /////////////////////////////////////////////////////////////////////////////
  1320. BOOL CAltExtWizardPostLauncherPage::OnSetActive( void )
  1321. {
  1322. //
  1323. // When moving forward just return FALSE so that we won't be displayed.
  1324. //
  1325. // When moving backward, display the alternate extension wizard and
  1326. // return TRUE so that we will be waiting for the alternate wizard to
  1327. // move us to the right place. Press the alternate wizard's Back button
  1328. // because it is waiting at the postfix page.
  1329. //
  1330. if ( Pwiz()->BNextPressed() )
  1331. {
  1332. return FALSE;
  1333. } // if: moving forward
  1334. else
  1335. {
  1336. ATLASSERT( Pwiz()->BBackPressed() );
  1337. //
  1338. // Display the alternate wizard.
  1339. //
  1340. CAltExtWizard * pwizAlt = reinterpret_cast< CAltExtWizard * >( Pwiz()->PwizAlternate() );
  1341. pwizAlt->PressButton( PSBTN_BACK );
  1342. pwizAlt->DisplayAlternateWizard();
  1343. //
  1344. // Execute the alternate wizard message loop.
  1345. // This required so that tabs and accelerator keys will work.
  1346. //
  1347. pwizAlt->MessageLoop();
  1348. return TRUE;
  1349. } // else: moving backward
  1350. } //*** CAltExtWizardPostLauncherPage::OnSetActive()
  1351. //*************************************************************************//
  1352. ////////////////////////////////////////////////////////////////////////////
  1353. // class CAltExtWizard
  1354. /////////////////////////////////////////////////////////////////////////////
  1355. /////////////////////////////////////////////////////////////////////////////
  1356. //++
  1357. //
  1358. // CAltExtWizard::BInit
  1359. //
  1360. // Routine Description:
  1361. // Initialize the wizard.
  1362. // This wizard is used to display extension pages that are different
  1363. // than the type of the main wizard, e.g. displaying non-Wizard97 pages
  1364. // in a Wizard97 wizard. This wizard will have a dummy prefix page
  1365. // and a dummy postfix page, which are only here to handle entering and
  1366. // exiting the wizard. This routine will add the prefix page, add the
  1367. // alternate extension pages from the main wizard, then add the postfix
  1368. // page.
  1369. //
  1370. // Arguments:
  1371. // pwizMain [IN] Main wizard.
  1372. //
  1373. // Return Value:
  1374. // TRUE Wizard initialized successfully.
  1375. // FALSE Error initializing wizard. Error already displayed.
  1376. //
  1377. //--
  1378. /////////////////////////////////////////////////////////////////////////////
  1379. BOOL CAltExtWizard::BInit( IN CWizardWindow * pwizMain )
  1380. {
  1381. ATLASSERT( pwizMain != NULL );
  1382. ATLASSERT( m_pwizMain == NULL );
  1383. BOOL bSuccess;
  1384. m_pwizMain = pwizMain;
  1385. //
  1386. // Setup the type of wizard to be the opposite of the main wizard.
  1387. //
  1388. m_psh.dwFlags &= ~PSH_PROPSHEETPAGE; // Using HPROPSHEETPAGEs.
  1389. if ( ! PwizMain()->BWizard97() )
  1390. {
  1391. // Don't add a watermark since we don't have a watermark bitmap.
  1392. m_psh.dwFlags &= ~(PSH_WIZARD
  1393. | PSH_WATERMARK
  1394. );
  1395. m_psh.dwFlags |= (PSH_WIZARD97
  1396. | PSH_HEADER
  1397. );
  1398. } // if: Wizard97 wizard
  1399. else
  1400. {
  1401. m_psh.dwFlags |= PSH_WIZARD;
  1402. m_psh.dwFlags &= ~(PSH_WIZARD97
  1403. | PSH_WATERMARK
  1404. | PSH_HEADER
  1405. );
  1406. } // else: non-Wizard97 wizard
  1407. // Loop to avoid goto's
  1408. do
  1409. {
  1410. //
  1411. // Get the first page in the main wizard.
  1412. //
  1413. HWND hwndChild = PwizMain()->GetWindow( GW_CHILD );
  1414. ATLASSERT( hwndChild != NULL );
  1415. //
  1416. // Get the current width and height of the child window.
  1417. //
  1418. CRect rect;
  1419. bSuccess = ::GetClientRect( hwndChild, &rect );
  1420. if ( ! bSuccess )
  1421. {
  1422. CNTException nte(
  1423. GetLastError(),
  1424. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1425. NULL,
  1426. NULL,
  1427. FALSE
  1428. );
  1429. nte.ReportError();
  1430. break;
  1431. } // if: error getting client rectangle
  1432. //
  1433. // Add a prefix page.
  1434. //
  1435. bSuccess = BAddPrefixPage( (WORD)rect.Width(), (WORD)rect.Height() );
  1436. if ( ! bSuccess )
  1437. {
  1438. break;
  1439. } // if: error adding the prefix page
  1440. //
  1441. // Add alternate pages from the main wizard to the wizard page list.
  1442. // They will be added to the wizard at sheet initialization time.
  1443. //
  1444. CExtensionWizardPageList::iterator itCurrent = PwizMain()->PlewpAlternate()->begin();
  1445. CExtensionWizardPageList::iterator itLast = PwizMain()->PlewpAlternate()->end();
  1446. while ( itCurrent != itLast )
  1447. {
  1448. CExtensionWizardPageWindow * pewp = *itCurrent;
  1449. ATLASSERT( pewp != NULL );
  1450. PlwpPages()->insert( PlwpPages()->end(), pewp );
  1451. PwizMain()->PlewpAlternate()->erase( itCurrent );
  1452. itCurrent = PwizMain()->PlewpAlternate()->begin();
  1453. } // for: each page in the list
  1454. //
  1455. // Add a postfix page.
  1456. //
  1457. bSuccess = BAddPostfixPage( (WORD) rect.Width(), (WORD) rect.Height() );
  1458. if ( ! bSuccess )
  1459. {
  1460. break;
  1461. } // if: error adding the postfix page
  1462. } while ( 0 );
  1463. //
  1464. // Call the base class.
  1465. //
  1466. if ( ! baseClass::BInit() )
  1467. {
  1468. return FALSE;
  1469. } // if: error initializing the base class
  1470. return bSuccess;
  1471. } //*** CAltExtWizard::BInit()
  1472. /////////////////////////////////////////////////////////////////////////////
  1473. //++
  1474. //
  1475. // CAltExtWizard::BAddPrefixPage
  1476. //
  1477. // Routine Description:
  1478. // Add a prefix page to the wizard.
  1479. //
  1480. // Arguments:
  1481. // cx [IN] Width of the page.
  1482. // cy [IN] Height of the page.
  1483. //
  1484. // Return Value:
  1485. // TRUE Page added successfully.
  1486. // FALSE Error adding the page. Error already displayed.
  1487. //
  1488. //--
  1489. /////////////////////////////////////////////////////////////////////////////
  1490. BOOL CAltExtWizard::BAddPrefixPage( IN WORD cx, IN WORD cy )
  1491. {
  1492. ATLASSERT( cx > 0 );
  1493. ATLASSERT( cy > 0 );
  1494. BOOL bSuccess;
  1495. DLGTEMPLATE * pdt = NULL;
  1496. CAltExtWizardPrefixPage * pwp = NULL;
  1497. // Loop to avoid goto's
  1498. do
  1499. {
  1500. //
  1501. // Create the dialog template for the page.
  1502. //
  1503. pdt = PdtCreateDummyPageDialogTemplate( cx, cy );
  1504. ATLASSERT( pdt != NULL );
  1505. if ( pdt == NULL )
  1506. {
  1507. bSuccess = FALSE;
  1508. break;
  1509. } // if: error creating the dialog template
  1510. //
  1511. // Adjust the page size so that we will be creating the same size
  1512. // wizard as the main wizard. Non-Wizard97 wizards add padding
  1513. // (7 DLUs on each side) whereas Wizard97 wizards add no padding
  1514. // to the first page, which is where we are expecting these
  1515. // dimensions to come from.
  1516. //
  1517. if ( BWizard97() )
  1518. {
  1519. pdt->cx += 7 * 2;
  1520. pdt->cy += 7 * 2;
  1521. } // if: Wizard97 wizard
  1522. else
  1523. {
  1524. pdt->cx -= 7 * 2;
  1525. pdt->cy -= 7 * 2;
  1526. } // else: non-Wizard97 wizard
  1527. //
  1528. // Allocate and initialize the page.
  1529. //
  1530. pwp = new CAltExtWizardPrefixPage( pdt );
  1531. ATLASSERT( pwp != NULL );
  1532. if ( pwp == NULL )
  1533. {
  1534. bSuccess = FALSE;
  1535. break;
  1536. } // if: error allocating the page
  1537. pdt = NULL;
  1538. bSuccess = pwp->BInit( this );
  1539. if ( ! bSuccess )
  1540. {
  1541. break;
  1542. } // if: error initializing the page
  1543. //
  1544. // Create the page.
  1545. //
  1546. DWORD sc = pwp->ScCreatePage();
  1547. if ( sc != ERROR_SUCCESS )
  1548. {
  1549. CNTException nte(
  1550. sc,
  1551. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1552. NULL,
  1553. NULL,
  1554. FALSE
  1555. );
  1556. nte.ReportError();
  1557. bSuccess = FALSE;
  1558. break;
  1559. } // if: error creating the page
  1560. //
  1561. // Add the page to the wizard.
  1562. //
  1563. bSuccess = BAddPage( pwp );
  1564. pwp = NULL;
  1565. } while ( 0 );
  1566. delete pwp;
  1567. delete pdt;
  1568. return bSuccess;
  1569. } //*** CAltExtWizard::BAddPrefixPage()
  1570. /////////////////////////////////////////////////////////////////////////////
  1571. //++
  1572. //
  1573. // CAltExtWizard::BAddPostfixPage
  1574. //
  1575. // Routine Description:
  1576. // Add a postfix page to the wizard.
  1577. //
  1578. // Arguments:
  1579. // cx [IN] Width of the page.
  1580. // cy [IN] Height of the page.
  1581. //
  1582. // Return Value:
  1583. // TRUE Page added successfully.
  1584. // FALSE Error adding the page. Error already displayed.
  1585. //
  1586. //--
  1587. /////////////////////////////////////////////////////////////////////////////
  1588. BOOL CAltExtWizard::BAddPostfixPage( IN WORD cx, IN WORD cy )
  1589. {
  1590. ATLASSERT( cx > 0 );
  1591. ATLASSERT( cy > 0 );
  1592. BOOL bSuccess;
  1593. DLGTEMPLATE * pdt = NULL;
  1594. CAltExtWizardPostfixPage * pwp = NULL;
  1595. // Loop to avoid goto's
  1596. do
  1597. {
  1598. //
  1599. // Create the dialog template for the page.
  1600. //
  1601. pdt = PdtCreateDummyPageDialogTemplate( cx, cy );
  1602. ATLASSERT( pdt != NULL );
  1603. if ( pdt == NULL )
  1604. {
  1605. bSuccess = FALSE;
  1606. break;
  1607. } // if: error creating the dialog template
  1608. //
  1609. // Adjust the page size so that we will be creating the same size
  1610. // wizard as the main wizard. Non-Wizard97 wizards add padding
  1611. // (7 DLUs on each side) whereas Wizard97 wizards add no padding
  1612. // to the first page, which is where we are expecting these
  1613. // dimensions to come from.
  1614. //
  1615. if ( BWizard97() )
  1616. {
  1617. pdt->cx += 7 * 2;
  1618. pdt->cy += 7 * 2;
  1619. } // if: Wizard97 wizard
  1620. else
  1621. {
  1622. pdt->cx -= 7 * 2;
  1623. pdt->cy -= 7 * 2;
  1624. } // else: non-Wizard97 wizard
  1625. //
  1626. // Allocate and initialize the page.
  1627. //
  1628. pwp = new CAltExtWizardPostfixPage( pdt );
  1629. ATLASSERT( pwp != NULL );
  1630. if ( pwp == NULL )
  1631. {
  1632. bSuccess = FALSE;
  1633. break;
  1634. } // if: error allocating the page
  1635. pdt = NULL;
  1636. bSuccess = pwp->BInit( this );
  1637. if ( ! bSuccess )
  1638. {
  1639. break;
  1640. } // if: error initializing the page
  1641. //
  1642. // Create the page.
  1643. //
  1644. DWORD sc = pwp->ScCreatePage();
  1645. if ( sc != ERROR_SUCCESS )
  1646. {
  1647. CNTException nte(
  1648. sc,
  1649. ADMC_IDS_INIT_EXT_PAGES_ERROR,
  1650. NULL,
  1651. NULL,
  1652. FALSE
  1653. );
  1654. nte.ReportError();
  1655. bSuccess = FALSE;
  1656. break;
  1657. } // if: error creating the page
  1658. //
  1659. // Add the page to the page list. It will be added to the wizard
  1660. // at sheet initialization time.
  1661. //
  1662. PlwpPages()->insert( PlwpPages()->end(), pwp );
  1663. pwp = NULL;
  1664. bSuccess = TRUE;
  1665. } while ( 0 );
  1666. delete pwp;
  1667. delete pdt;
  1668. return bSuccess;
  1669. } //*** CAltExtWizard::BAddPostfixPage()
  1670. /////////////////////////////////////////////////////////////////////////////
  1671. //++
  1672. //
  1673. // CAltExtWizard::DisplayAlternateWizard
  1674. //
  1675. // Routine Description:
  1676. // Display the alternate wizard. This involved the following steps:
  1677. // -- Move the alternate wizard to the position of the main wizard.
  1678. // -- Show the alternate wizard.
  1679. // -- Hide the main wizard.
  1680. //
  1681. // Arguments:
  1682. // None.
  1683. //
  1684. // Return Value:
  1685. // None.
  1686. //
  1687. // Exceptions Thrown:
  1688. // None.
  1689. //
  1690. //--
  1691. /////////////////////////////////////////////////////////////////////////////
  1692. void CAltExtWizard::DisplayAlternateWizard( void )
  1693. {
  1694. //
  1695. // Move the alternate wizard to where the main wizard is positioned.
  1696. //
  1697. CRect rectMain;
  1698. CRect rectAlt;
  1699. CRect rectNew;
  1700. if ( PwizMain()->GetWindowRect( &rectMain ) )
  1701. {
  1702. if ( GetWindowRect( &rectAlt ) )
  1703. {
  1704. //ATLTRACE( _T("CAltExtWizard::DisplayAlternateWizard() - Main = (%d,%d) (%d,%d) Alt = (%d,%d) (%d,%d)\n"),
  1705. // rectMain.left, rectMain.right, rectMain.top, rectMain.bottom,
  1706. // rectAlt.left, rectAlt.right, rectAlt.top, rectAlt.bottom );
  1707. rectNew.left = rectMain.left;
  1708. rectNew.top = rectMain.top;
  1709. rectNew.right = rectNew.left + rectAlt.Width();
  1710. rectNew.bottom = rectNew.top + rectAlt.Height();
  1711. MoveWindow( &rectNew );
  1712. } // if: got the alternate wizard's window rectangle successfully
  1713. } // if: got the main wizard's window rectangle successfully
  1714. //
  1715. // Show the alternate wizard and hide the main wizard.
  1716. //
  1717. ShowWindow( SW_SHOW );
  1718. PwizMain()->ShowWindow( SW_HIDE );
  1719. SetActiveWindow();
  1720. PwizMain()->SetCurrentWizard( this );
  1721. } //*** CAltExtWizard::DisplayAlternateWizard()
  1722. /////////////////////////////////////////////////////////////////////////////
  1723. //++
  1724. //
  1725. // CAltExtWizard::DisplayMainWizard
  1726. //
  1727. // Routine Description:
  1728. // Display the main wizard. This involved the following steps:
  1729. // -- Move the main wizard to the position of the alternate wizard.
  1730. // -- Show the main wizard.
  1731. // -- Hide the alternate wizard.
  1732. //
  1733. // Arguments:
  1734. // None.
  1735. //
  1736. // Return Value:
  1737. // None.
  1738. //
  1739. // Exceptions Thrown:
  1740. // None.
  1741. //
  1742. //--
  1743. /////////////////////////////////////////////////////////////////////////////
  1744. void CAltExtWizard::DisplayMainWizard( void )
  1745. {
  1746. //
  1747. // Move the main wizard to where the alternate wizard is positioned.
  1748. //
  1749. CRect rectMain;
  1750. CRect rectAlt;
  1751. CRect rectNew;
  1752. if ( PwizMain()->GetWindowRect( &rectMain ) )
  1753. {
  1754. if ( GetWindowRect( &rectAlt ) )
  1755. {
  1756. //ATLTRACE( _T("CAltExtWizard::DisplayMainWizard() - Main = (%d,%d) (%d,%d) Alt = (%d,%d) (%d,%d)\n"),
  1757. // rectMain.left, rectMain.right, rectMain.top, rectMain.bottom,
  1758. // rectAlt.left, rectAlt.right, rectAlt.top, rectAlt.bottom );
  1759. rectNew.left = rectAlt.left;
  1760. rectNew.top = rectAlt.top;
  1761. rectNew.right = rectNew.left + rectMain.Width();
  1762. rectNew.bottom = rectNew.top + rectMain.Height();
  1763. PwizMain()->MoveWindow( &rectNew );
  1764. } // if: got the alternate wizard's window rectangle successfully
  1765. } // if: got the main wizard's window rectangle successfully
  1766. //
  1767. // Show the main wizard and hide the alternate wizard.
  1768. //
  1769. PwizMain()->ShowWindow( SW_SHOW );
  1770. PwizMain()->SetActiveWindow();
  1771. ShowWindow( SW_HIDE );
  1772. PwizMain()->SetCurrentWizard( PwizMain() );
  1773. } //*** CAltExtWizard::DisplayMainWizard()
  1774. /////////////////////////////////////////////////////////////////////////////
  1775. //++
  1776. //
  1777. // CAltExtWizard::DestroyAlternateWizard
  1778. //
  1779. // Routine Description:
  1780. // Destroy the alternate extension wizard.
  1781. //
  1782. // Arguments:
  1783. // None.
  1784. //
  1785. // Return Value:
  1786. // None.
  1787. //
  1788. //--
  1789. /////////////////////////////////////////////////////////////////////////////
  1790. void CAltExtWizard::DestroyAlternateWizard( void )
  1791. {
  1792. ATLASSERT( m_hWnd != NULL );
  1793. //
  1794. // Press the Cancel button on the alternate wizard.
  1795. //
  1796. PressButton( PSBTN_CANCEL );
  1797. //
  1798. // Destroy the wizard.
  1799. //
  1800. DestroyWindow();
  1801. } //*** CAltExtWizard::DestroyAlternateWizard()
  1802. /////////////////////////////////////////////////////////////////////////////
  1803. //++
  1804. //
  1805. // CAltExtWizard::MessageLoop
  1806. //
  1807. // Routine Description:
  1808. // Message loop for this wizard as a modeless wizard.
  1809. //
  1810. // Arguments:
  1811. // None.
  1812. //
  1813. // Return Value:
  1814. // None.
  1815. //
  1816. //--
  1817. /////////////////////////////////////////////////////////////////////////////
  1818. void CAltExtWizard::MessageLoop( void )
  1819. {
  1820. MSG msg;
  1821. m_bExitMsgLoop = FALSE;
  1822. while ( (GetActivePage() != NULL)
  1823. && GetMessage( &msg, NULL, 0, 0 ) )
  1824. {
  1825. //
  1826. // Ask the wizard if it wants to process it. If not, go ahead
  1827. // and translate it and dispatch it.
  1828. //
  1829. if ( ! IsDialogMessage( &msg ) )
  1830. {
  1831. TranslateMessage( &msg );
  1832. DispatchMessage( &msg );
  1833. } // if: not a property sheet dialog message
  1834. //
  1835. // If the dialog is done, exit this loop.
  1836. //
  1837. if ( BExitMessageLoop() )
  1838. {
  1839. DisplayMainWizard();
  1840. PwizMain()->PostMessage( PSM_PRESSBUTTON, NExitButton(), 0 );
  1841. break;
  1842. } // if: exiting the wizard
  1843. } // while: active page and not quitting
  1844. } //*** CAltExtWizard::MessageLoop()
  1845. //*************************************************************************//
  1846. ////////////////////////////////////////////////////////////////////////////
  1847. // class CAltExtWizardPrefixPage
  1848. /////////////////////////////////////////////////////////////////////////////
  1849. /////////////////////////////////////////////////////////////////////////////
  1850. //++
  1851. //
  1852. // CAltExtWizardPrefixPage::OnSetActive
  1853. //
  1854. // Routine Description:
  1855. // Handler for PSN_SETACTIVE.
  1856. // This page manages the transfer of control between the main wizard
  1857. // and the first page of the alternate wizard.
  1858. //
  1859. // Arguments:
  1860. // None.
  1861. //
  1862. // Return Value:
  1863. // TRUE Page activated successfully.
  1864. // FALSE Error activating page.
  1865. //
  1866. //--
  1867. /////////////////////////////////////////////////////////////////////////////
  1868. BOOL CAltExtWizardPrefixPage::OnSetActive( void )
  1869. {
  1870. //
  1871. // When moving forward, display the alternate wizard and return FALSE
  1872. // so that this page won't be displayed.
  1873. //
  1874. // When moving backward, display the main wizard and return TRUE so that
  1875. // we'll be waiting for the main wizard to do something with us.
  1876. //
  1877. if ( Pwiz()->BBackPressed() )
  1878. {
  1879. PwizThis()->ExitMessageLoop( PSBTN_BACK );
  1880. return TRUE;
  1881. } // if: moving backward
  1882. else
  1883. {
  1884. PwizThis()->DisplayAlternateWizard();
  1885. return FALSE;
  1886. } // if: moving forward
  1887. } //*** CAltExtWizardPrefixPage::OnSetActive()
  1888. //*************************************************************************//
  1889. ////////////////////////////////////////////////////////////////////////////
  1890. // class CAltExtWizardPostfixPage
  1891. /////////////////////////////////////////////////////////////////////////////
  1892. /////////////////////////////////////////////////////////////////////////////
  1893. //++
  1894. //
  1895. // CAltExtWizardPostfixPage::OnSetActive
  1896. //
  1897. // Routine Description:
  1898. // Handler for PSN_SETACTIVE.
  1899. // This page manages the transfer of control between the main wizard
  1900. // and the last page of the alternate wizard.
  1901. //
  1902. // Arguments:
  1903. // None.
  1904. //
  1905. // Return Value:
  1906. // TRUE Page activated successfully.
  1907. // FALSE Error activating page.
  1908. //
  1909. //--
  1910. /////////////////////////////////////////////////////////////////////////////
  1911. BOOL CAltExtWizardPostfixPage::OnSetActive( void )
  1912. {
  1913. //
  1914. // When moving forward display the main wizard and return TRUE so that
  1915. // we'll be waiting for the main wizard to tell us what to do next.
  1916. //
  1917. // This routine should never be called when moving backward.
  1918. //
  1919. ATLASSERT( Pwiz()->BNextPressed() );
  1920. //
  1921. // Display the main wizard.
  1922. //
  1923. PwizThis()->ExitMessageLoop( PSBTN_NEXT );
  1924. return TRUE;
  1925. } //*** CAltExtWizardPostfixPage::OnSetActive()
  1926. //*************************************************************************//
  1927. /////////////////////////////////////////////////////////////////////////////
  1928. // Global Functions
  1929. /////////////////////////////////////////////////////////////////////////////
  1930. /////////////////////////////////////////////////////////////////////////////
  1931. //++
  1932. //
  1933. // PdtCreateDummyPageDialogTemplate
  1934. //
  1935. // Routine Description:
  1936. // Create a dialog template in memory for use on a dummy page.
  1937. //
  1938. // Arguments:
  1939. // cx [IN] Width of the dialog in pixels.
  1940. // cy [IN] Height of the dialog in pixels.
  1941. //
  1942. // Return Value:
  1943. // ppDlgTemplate Dialog template.
  1944. //
  1945. //--
  1946. /////////////////////////////////////////////////////////////////////////////
  1947. DLGTEMPLATE * PdtCreateDummyPageDialogTemplate( IN WORD cx, IN WORD cy )
  1948. {
  1949. static const WCHAR s_szFontName[] = L"MS Shell Dlg";
  1950. struct FULLDLGTEMPLATE : public DLGTEMPLATE
  1951. {
  1952. WORD nMenuID;
  1953. WORD nClassID;
  1954. WORD nTitle;
  1955. WORD nFontSize;
  1956. WCHAR szFontName[ RTL_NUMBER_OF( s_szFontName ) ];
  1957. };
  1958. HRESULT hr;
  1959. FULLDLGTEMPLATE * pDlgTemplate = new FULLDLGTEMPLATE;
  1960. ATLASSERT( pDlgTemplate != NULL );
  1961. if ( pDlgTemplate != NULL )
  1962. {
  1963. pDlgTemplate->style = WS_CHILD | WS_DISABLED | WS_SYSMENU | DS_SETFONT;
  1964. pDlgTemplate->dwExtendedStyle = 0;
  1965. pDlgTemplate->cdit = 0;
  1966. pDlgTemplate->x = 0;
  1967. pDlgTemplate->y = 0;
  1968. pDlgTemplate->cx = ((cx * 2) + (3 / 2)) / 3; // round off
  1969. pDlgTemplate->cy = ((cy * 8) + (13 / 2)) / 13; // round off
  1970. pDlgTemplate->nMenuID = 0;
  1971. pDlgTemplate->nClassID = 0;
  1972. pDlgTemplate->nTitle = 0;
  1973. pDlgTemplate->nFontSize = 8;
  1974. hr = StringCchCopyNW( pDlgTemplate->szFontName, RTL_NUMBER_OF( pDlgTemplate->szFontName ), s_szFontName, RTL_NUMBER_OF( s_szFontName ) );
  1975. ATLASSERT( SUCCEEDED( hr ) );
  1976. } // if: dialog template allocated successfully
  1977. return pDlgTemplate;
  1978. } //*** PdtCreateDummyPageDialogTemplate()