home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / appwiz / hierwiz / chooser.cpp next >
C/C++ Source or Header  |  1998-03-05  |  2KB  |  74 lines

  1. // chooser.cpp : Implements the CDialogChooser class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "hierwiz.h"
  15. #include "chooser.h"
  16. #include "loadfile.h"
  17. #include "editdlg.h"
  18.  
  19. #ifdef _PSEUDO_DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. // On construction, set up internal array with pointers to each step.
  25. CDialogChooser::CDialogChooser()
  26. {
  27.     m_pDlgs[START_PAGE] = NULL;
  28.  
  29.     m_pDlgs[FEATURES_PAGE] = new CCustom1Dlg;
  30.     m_pDlgs[LOADFILE_PAGE] = new CLoadFileDlg ;
  31.     m_pDlgs[EDITDATA_PAGE] = new CEditDlg;
  32.  
  33.     m_nCurrDlg = 0;
  34. }
  35. // Remember where the custom steps begin, so we can delete them in
  36. //  the destructor
  37. #define FIRST_CUSTOM_STEP 1
  38. #define LAST_CUSTOM_STEP 3
  39.  
  40. // The destructor deletes entries in the internal array corresponding to
  41. //  custom steps.
  42. CDialogChooser::~CDialogChooser()
  43. {
  44.     for (int i = FIRST_CUSTOM_STEP; i <= LAST_CUSTOM_STEP; i++)
  45.     {
  46.         ASSERT(m_pDlgs[i] != NULL);
  47.         delete m_pDlgs[i];
  48.     }
  49. }
  50.  
  51. // Use the internal array to determine the next step.
  52. CAppWizStepDlg* CDialogChooser::Next(CAppWizStepDlg* pDlg)
  53. {
  54.     ASSERT(0 <= m_nCurrDlg && m_nCurrDlg < LAST_DLG);
  55.  
  56.     m_nCurrDlg++ ;
  57.     if(pDlg == m_pDlgs[FEATURES_PAGE]) // If the features page is active
  58.         return m_pDlgs[CCustom1Dlg::m_DataSource] ;
  59.  
  60.     return m_pDlgs[m_nCurrDlg] ;
  61. }
  62.  
  63. // Use the internal array to determine the previous step.
  64. CAppWizStepDlg* CDialogChooser::Back(CAppWizStepDlg* pDlg)
  65. {
  66.     ASSERT(1 <= m_nCurrDlg && m_nCurrDlg <= LAST_DLG);
  67.  
  68.     m_nCurrDlg--;
  69.     if(pDlg == m_pDlgs[FEATURES_PAGE])
  70.         return m_pDlgs[START_PAGE];
  71.     else
  72.         return m_pDlgs[FEATURES_PAGE];
  73. }
  74.