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

  1. // chooser.cpp : Implements the CDialogChooser class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "$$root$$.h"
  6. #include "chooser.h"
  7. $$BEGINLOOP(NUM_NEW_STEPS)
  8. #include "cstm$$ITERATOR$$dlg.h"
  9. $$ENDLOOP
  10. $$IF(APWZSEQ_EXE)
  11. #include "$$filebase$$aw.h"
  12. $$ENDIF //APWZSEQ_EXE
  13.  
  14. #ifdef _PSEUDO_DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. // On construction, set up internal array with pointers to each step.
  20. CDialogChooser::CDialogChooser()
  21. {
  22.     m_pDlgs[0] = NULL;
  23. $$IF(APWZSEQ_EXE)
  24.  
  25.     m_pDlgs[1] = GetDialog(APWZDLG_APPTYPE);
  26.     m_pDlgs[2] = GetDialog(APWZDLG_DATABASE);
  27.     m_pDlgs[3] = GetDialog(APWZDLG_OLE);
  28.     m_pDlgs[4] = GetDialog(APWZDLG_DOCAPPOPTIONS);
  29.     m_pDlgs[5] = GetDialog(APWZDLG_PROJOPTIONS);
  30.     m_pDlgs[6] = GetDialog(APWZDLG_CLASSES);
  31.     m_pDlgs[7] = GetDialog(APWZDLG_DLGAPPOPTIONS);
  32. $$ELIF(APWZSEQ_DLL)
  33.  
  34.     m_pDlgs[1] = GetDialog(APWZDLG_DLLPROJOPTIONS);
  35. $$ENDIF //APWZSEQ_EXE,_DLL
  36. $$IF(HAS_NEW_STEPS)
  37.  
  38. $$BEGINLOOP(NUM_NEW_STEPS)
  39.     m_pDlgs[$$MPDLGS_INDEX$$] = new CCustom$$ITERATOR$$Dlg;
  40. $$ENDLOOP
  41. $$ENDIF //HAS_NEW_STEPS
  42.  
  43.     m_nCurrDlg = 0;
  44. $$IF(APWZSEQ_EXE)
  45.     m_nTrack = 0;
  46. $$ENDIF
  47. }
  48. $$IF(HAS_NEW_STEPS)
  49. // Remember where the custom steps begin, so we can delete them in
  50. //  the destructor
  51. #define FIRST_CUSTOM_STEP $$MPDLGS_INDEX_0$$
  52. #define LAST_CUSTOM_STEP $$MPDLGS_INDEX_LAST$$
  53. $$ENDIF //HAS_NEW_STEPS
  54. $$IF(APWZSEQ_EXE)
  55.  
  56. // Set up arrays of indices to simulate behavior of AppWizard (i.e., to have
  57. //  separate "tracks" for an MDI/SDI app and a dialog-based app).
  58. static int nDocTrack[] = {0, 1, 2, 3, 4, 5, 6$$CUSTOM_INDICES$$};
  59. static int nDlgTrack[] = {0, 1, 7, 5, 6$$CUSTOM_INDICES$$};
  60. static int* pnTrack[] = {nDocTrack, nDlgTrack};
  61. static int nLast[] = {$$LAST_DOCTRACK_INDEX$$, $$LAST_DLGTRACK_INDEX$$};
  62. $$ENDIF //APWZSEQ_EXE
  63. $$IF(HAS_NEW_STEPS)
  64.  
  65. // The destructor deletes entries in the internal array corresponding to
  66. //  custom steps.
  67. CDialogChooser::~CDialogChooser()
  68. {
  69. $$IF(CUSTOMTYPE_SEQUENCE)
  70.     // NOTE: Be sure to delete all of your custom steps here, but don't delete
  71.     //  any standard AppWizard steps you got through the GetDialog API.
  72. $$ENDIF //CUSTOMTYPE_SEQUENCE
  73.     for (int i = FIRST_CUSTOM_STEP; i <= LAST_CUSTOM_STEP; i++)
  74.     {
  75.         ASSERT(m_pDlgs[i] != NULL);
  76.         delete m_pDlgs[i];
  77.     }
  78. }
  79. $$ENDIF //HAS_NEW_STEPS
  80.  
  81. // Use the internal array to determine the next step.
  82. CAppWizStepDlg* CDialogChooser::Next(CAppWizStepDlg* pDlg)
  83. {
  84. $$IF(APWZSEQ_EXE)
  85.     ASSERT(m_nTrack == 0 || m_nTrack == 1);
  86.     ASSERT(0 <= m_nCurrDlg && m_nCurrDlg < nLast[m_nTrack]);
  87.     ASSERT(pDlg == m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]]);
  88.  
  89.     // If the current step is the "project type" step, the AppWizard "track" may
  90.     //  have changed.
  91.     if (m_nCurrDlg == 1)
  92.     {
  93.         CString strTemp;
  94.         m_nTrack = $$safe_root$$aw.m_Dictionary.Lookup(_T("PROJTYPE_DLG"), strTemp) ? 1 : 0;
  95.         SetNumberOfSteps(nLast[m_nTrack]);
  96.     }
  97.  
  98.     m_nCurrDlg++;
  99.  
  100.     // If the new step is the "project type" step, don't display the max number
  101.     //  of steps.
  102.     if (m_nCurrDlg == 1)
  103.         SetNumberOfSteps(-1);
  104.  
  105.     return m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]];
  106. $$ELSE //!APWZSEQ_EXE
  107.     ASSERT(0 <= m_nCurrDlg && m_nCurrDlg < LAST_DLG);
  108.     ASSERT(pDlg == m_pDlgs[m_nCurrDlg]);
  109.  
  110.     m_nCurrDlg++;
  111.     return m_pDlgs[m_nCurrDlg];
  112. $$ENDIF //APWZSEQ_EXE
  113. }
  114.  
  115. // Use the internal array to determine the previous step.
  116. CAppWizStepDlg* CDialogChooser::Back(CAppWizStepDlg* pDlg)
  117. {
  118. $$IF(APWZSEQ_EXE)
  119.     ASSERT(m_nTrack == 0 || m_nTrack == 1);
  120.     ASSERT(1 <= m_nCurrDlg && m_nCurrDlg <= nLast[m_nTrack]);
  121.     ASSERT(pDlg == m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]]);
  122.  
  123.     m_nCurrDlg--;
  124.  
  125.     // If the new step is the "project type" step, don't display the max number
  126.     //  of steps.
  127.     if (m_nCurrDlg == 1)
  128.         SetNumberOfSteps(-1);
  129.  
  130.     return m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]];
  131. $$ELSE //!APWZSEQ_EXE
  132.     ASSERT(1 <= m_nCurrDlg && m_nCurrDlg <= LAST_DLG);
  133.     ASSERT(pDlg == m_pDlgs[m_nCurrDlg]);
  134.  
  135.     m_nCurrDlg--;
  136.     return m_pDlgs[m_nCurrDlg];
  137. $$ENDIF //APWZSEQ_EXE
  138. }
  139.