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

  1. // chooser.cpp : Implements the CDialogChooser class
  2. //
  3. // This class is where you set up the sequence of steps that will
  4. // be followed in your custom AppWizard.  These steps can include
  5. // both standard AppWizard steps and your own custom steps.
  6. //
  7. // This is a part of the Microsoft Foundation Classes C++ library.
  8. // Copyright (C) 1995 Microsoft Corporation
  9. // All rights reserved.
  10. //
  11. // This source code is only intended as a supplement to the
  12. // Microsoft Foundation Classes Reference and related
  13. // electronic documentation provided with the library.
  14. // See these sources for detailed information regarding the
  15. // Microsoft Foundation Classes product.
  16.  
  17. #include "stdafx.h"
  18. #include "logowiz.h"
  19. #include "chooser.h"
  20. #include "cstm1dlg.h"
  21. #include "logowaw.h"
  22.  
  23. #ifdef _PSEUDO_DEBUG
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. #define DOC_TRACK   0   // MDI/SDI based app track
  29. #define DLG_TRACK   1   // dialog based app track
  30.  
  31. // define the steps, since these are array indices, their values matter
  32. #define STEP_ZERO           0
  33. #define STEP_APPTYPE        1
  34. //#define STEP_DATABASE     2   // closed gap 'cause we dropped this one
  35. #define STEP_OLE            2
  36. #define STEP_DOCOPTIONS     3
  37. #define STEP_PROJOPTIONS    4
  38. #define STEP_CLASSES        5
  39. #define STEP_DLGOPTIONS     6
  40. #define STEP_CUSTOM         7
  41.  
  42. // On construction, set up internal array with pointers to each step.
  43. CDialogChooser::CDialogChooser()
  44. {
  45.     m_pDlgs[STEP_ZERO] = NULL;
  46.  
  47.     m_pDlgs[STEP_APPTYPE] = GetDialog(APWZDLG_APPTYPE);
  48.     // m_pDlgs[STEP_DATABASE] = GetDialog(APWZDLG_DATABASE);
  49.     m_pDlgs[STEP_OLE] = GetDialog(APWZDLG_OLE);
  50.     m_pDlgs[STEP_DOCOPTIONS] = GetDialog(APWZDLG_DOCAPPOPTIONS);
  51.     m_pDlgs[STEP_PROJOPTIONS] = GetDialog(APWZDLG_PROJOPTIONS);
  52.     m_pDlgs[STEP_CLASSES] = GetDialog(APWZDLG_CLASSES);
  53.     m_pDlgs[STEP_DLGOPTIONS] = GetDialog(APWZDLG_DLGAPPOPTIONS);
  54.  
  55.     m_pDlgs[STEP_CUSTOM] = new CCustom1Dlg;
  56.  
  57.     m_nCurrDlg = STEP_ZERO;
  58.     m_nTrack = DOC_TRACK;
  59. }
  60. // Remember where the custom steps begin, so we can delete them in
  61. //  the destructor
  62. #define FIRST_CUSTOM_STEP 7
  63. #define LAST_CUSTOM_STEP 7
  64.  
  65. // Set up arrays of indices to simulate behavior of AppWizard (i.e., to have
  66. //  separate "tracks" for an MDI/SDI app and a dialog-based app).
  67. // There are two things being illustrated here:
  68. //  1.  there is a custom step added for the dialog-based app
  69. //  2.  the ODBC step is left out for the MDI/SDI app
  70. //static int nDocTrack[] = {STEP_ZERO, STEP_APPTYPE, STEP_DATABASE,
  71. //  STEP_OLE, STEP_DOCOPTIONS, STEP_PROJOPTIONS, STEP_CLASSES, STEP_CUSTOM};
  72. static int nDocTrack[] = {STEP_ZERO, STEP_APPTYPE, STEP_OLE,
  73.     STEP_DOCOPTIONS, STEP_PROJOPTIONS, STEP_CLASSES};
  74. //static int nDlgTrack[] = {STEP_ZERO, STEP_APPTYPE, STEP_DLGOPTIONS, STEP_PROJOPTIONS, STEP_CLASSES, STEP_CUSTOM};
  75. static int nDlgTrack[] = {STEP_ZERO, STEP_APPTYPE, STEP_DLGOPTIONS, STEP_PROJOPTIONS, STEP_CUSTOM, STEP_CLASSES};
  76. static int* pnTrack[] = {nDocTrack, nDlgTrack};
  77. //static int nLast[] = {STEP_CUSTOM, STEP_CLASSES};
  78. static int nLast[] = {STEP_CLASSES, STEP_CLASSES};
  79.  
  80. // The destructor deletes entries in the internal array corresponding to
  81. //  custom steps.
  82. CDialogChooser::~CDialogChooser()
  83. {
  84.     // NOTE: Be sure to delete all of your custom steps here, but don't delete
  85.     //  any standard AppWizard steps you got through the GetDialog API.
  86.     for (int i = FIRST_CUSTOM_STEP; i <= LAST_CUSTOM_STEP; i++)
  87.     {
  88.         ASSERT(m_pDlgs[i] != NULL);
  89.         delete m_pDlgs[i];
  90.     }
  91. }
  92.  
  93. // Use the internal array to determine the next step.
  94. CAppWizStepDlg* CDialogChooser::Next(CAppWizStepDlg* pDlg)
  95. {
  96.     ASSERT(m_nTrack == DOC_TRACK || m_nTrack == DLG_TRACK);
  97.     ASSERT(0 <= m_nCurrDlg && m_nCurrDlg < nLast[m_nTrack]);
  98.     ASSERT(pDlg == m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]]);
  99.  
  100.     // If the current step is the "project type" step, the AppWizard "track" may
  101.     //  have changed.
  102.     if (m_nCurrDlg == STEP_APPTYPE)
  103.     {
  104.         CString strTemp;
  105.         m_nTrack = logowizaw.m_Dictionary.Lookup(_T("PROJTYPE_DLG"), strTemp) ? 1 : 0;
  106.         SetNumberOfSteps(nLast[m_nTrack]);
  107.     }
  108.  
  109.     m_nCurrDlg++;
  110.  
  111.     // If the new step is the "project type" step, don't display the max number
  112.     //  of steps.
  113.     if (m_nCurrDlg == STEP_APPTYPE)
  114.         SetNumberOfSteps(-1);
  115.  
  116.     return m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]];
  117. }
  118.  
  119. // Use the internal array to determine the previous step.
  120. CAppWizStepDlg* CDialogChooser::Back(CAppWizStepDlg* pDlg)
  121. {
  122.     ASSERT(m_nTrack == DOC_TRACK || m_nTrack == DLG_TRACK);
  123.     ASSERT(1 <= m_nCurrDlg && m_nCurrDlg <= nLast[m_nTrack]);
  124.     ASSERT(pDlg == m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]]);
  125.  
  126.     m_nCurrDlg--;
  127.  
  128.     // If the new step is the "project type" step, don't display the max number
  129.     //  of steps.
  130.     if (m_nCurrDlg == STEP_APPTYPE)
  131.         SetNumberOfSteps(-1);
  132.  
  133.     return m_pDlgs[(pnTrack[m_nTrack])[m_nCurrDlg]];
  134. }
  135.