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

  1. // options.cpp : implementation of COptions class
  2. //
  3. // Copyright (c) 1985-1998, Microsoft Corporation. All rights reserved.
  4. //
  5.  
  6. #include "stdafx.h"
  7. #include "customwz.h"
  8. #include "sampleaw.h"
  9. #include "options.h"
  10. #include "typedlg.h"
  11. #include "seqdlg.h"
  12.  
  13. #ifdef _PSEUDO_DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18.  
  19. // On construction, set the default values of user-selectable options
  20. COptions::COptions()
  21. {
  22.     m_nCustomType = CUSTOMTYPE_ZAP;
  23.     m_nCustomSteps = 1;
  24.     m_nApwzSeq = APWZSEQ_EXE;
  25. }
  26.  
  27. #define FIRST_DLG_RSC 129   // For entries in generated custom appwiz's resource.h
  28.  
  29.  
  30. // These must be in the same order as the corresponding enum & radio buttons
  31. static LPCTSTR lpszApwzSeqMacros[] =
  32. {
  33.     _T("APWZSEQ_EXE"),
  34.     _T("APWZSEQ_DLL"),
  35. };
  36.  
  37. // Defines step-related template macros, which depend on which
  38. //  options were selected.
  39. void COptions::DefineDlgMacros()
  40. {
  41.     for (UINT i=0; i < APWZSEQ_MAX; i++)
  42.         DefineBoolMacro(lpszApwzSeqMacros[i], FALSE);
  43.  
  44.     // Determine the number of standard AppWizard steps in the generated
  45.     //  custom AppWizard
  46.     int nApwzSteps = 0;
  47.     if (m_nCustomType == CUSTOMTYPE_SEQUENCE)
  48.     {
  49.         nApwzSteps = (m_nApwzSeq == APWZSEQ_EXE) ?
  50.             NUM_APWZ_EXE_STEPS : NUM_APWZ_DLL_STEPS;
  51.  
  52.         // Set macro corresponding to the AppWizard sequence (exe or dll) off of which
  53.         //  we're basing this custom AppWizard (reset the others).
  54.         ASSERT(m_nApwzSeq == 0 || m_nApwzSeq == 1);
  55.         DefineBoolMacro(lpszApwzSeqMacros[m_nApwzSeq], TRUE);
  56.     }
  57.  
  58.     // Set custom-dialog-dependent macros as appropriate
  59.  
  60.     DefineBoolMacro(_T("HAS_NEW_STEPS"), m_nCustomSteps != 0);
  61.  
  62.     ASSERT(m_nCustomSteps < 10);
  63.  
  64.     DefineIntMacro(_T("NUM_NEW_STEPS"), m_nCustomSteps);
  65.     DefineIntMacro(_T("MPDLGS_INDEX_LAST"), m_nCustomSteps + nApwzSteps);
  66.     DefineIntMacro(_T("LAST_DOCTRACK_INDEX"), m_nCustomSteps + NUM_APWZ_EXE_DOC_STEPS);
  67.     DefineIntMacro(_T("LAST_DLGTRACK_INDEX"), m_nCustomSteps + NUM_APWZ_EXE_DLG_STEPS);
  68.  
  69.     CString strCustomIndices;
  70.     for (i=0; i < m_nCustomSteps; i++)
  71.     {
  72.         DefineIntMacro(_T("ITERATOR"), i, i+1);
  73.         DefineIntMacro(_T("DLGID_VALUE"), i,  i + FIRST_DLG_RSC);
  74.         DefineIntMacro(_T("MPDLGS_INDEX"), i, nApwzSteps + i + 1);
  75.  
  76.         CString strCustomIndex;
  77.         strCustomIndex.Format(_T(", %d"), nApwzSteps + i + 1);
  78.         strCustomIndices += strCustomIndex;
  79.     }
  80.     DefineStringMacro(_T("CUSTOM_INDICES"), strCustomIndices);
  81. }
  82.  
  83. // Create one global instance of this class anyone can see.
  84. COptions g_options;
  85.