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 / newaw.cpp < prev    next >
C/C++ Source or Header  |  1998-03-05  |  5KB  |  151 lines

  1. // $$filebase$$aw.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "$$root$$.h"
  6. #include "$$filebase$$aw.h"
  7. $$IF(HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE)
  8. #include "chooser.h"
  9. $$ENDIF //HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE
  10.  
  11. #ifdef _PSEUDO_DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. // This is called immediately after the custom AppWizard is loaded.  Initialize
  17. //  the state of the custom AppWizard here.
  18. void C$$Safe_root$$AppWiz::InitCustomAppWiz()
  19. {
  20. $$IF(HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE)
  21.     // Create a new dialog chooser; CDialogChooser's constructor initializes
  22.     //  its internal array with pointers to the steps.
  23.     m_pChooser = new CDialogChooser;
  24.  
  25. $$ENDIF
  26. $$IF(APWZSEQ_EXE)
  27.     // At first, we don't know the total number of steps, since there are two
  28.     //  possible "tracks" (MDI/SDI app and dialog-based app).
  29.     SetNumberOfSteps(-1);
  30.  
  31.     // Inform AppWizard of the languages we support
  32.     SetSupportedLanguages(_T("$$SUPPORTED_LANGS$$"));
  33. $$ELIF(APWZSEQ_DLL)
  34.     // Set the maximum number of steps.
  35.     SetNumberOfSteps(LAST_DLG);
  36.  
  37.     // Inform AppWizard that we're making a DLL.
  38.     m_Dictionary[_T("PROJTYPE_DLL")] = _T("1");
  39. $$ELIF(CUSTOMTYPE_ZAP || !HAS_NEW_STEPS)
  40.     // There are no steps in this custom AppWizard.
  41.     SetNumberOfSteps(0);
  42. $$IF(CUSTOMTYPE_ZAP)
  43.  
  44.     // Add build step to .hpj if there is one
  45.     m_Dictionary[_T("HELP")] = _T("1");
  46. $$IF(CREATE_DLL_PROJECT)
  47.  
  48.     // Inform AppWizard that we're making a DLL.
  49.     m_Dictionary[_T("PROJTYPE_DLL")] = _T("1");
  50. $$ENDIF //CREATE_DLL_PROJECT
  51. $$ENDIF //CUSTOMTYPE_ZAP
  52. $$ELSE
  53.     // Set the maximum number of steps.
  54.     SetNumberOfSteps(LAST_DLG);
  55. $$ENDIF
  56.  
  57.     // TODO: Add any other custom AppWizard-wide initialization here.
  58. }
  59.  
  60. // This is called just before the custom AppWizard is unloaded.
  61. void C$$Safe_root$$AppWiz::ExitCustomAppWiz()
  62. {
  63. $$IF(HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE)
  64.     // Deallocate memory used for the dialog chooser
  65.     ASSERT(m_pChooser != NULL);
  66.     delete m_pChooser;
  67.     m_pChooser = NULL;
  68.  
  69. $$ENDIF //HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE
  70.     // TODO: Add code here to deallocate resources used by the custom AppWizard
  71. }
  72.  
  73. // This is called when the user clicks "Create..." on the New Project dialog
  74. $$IF(!CUSTOMTYPE_ZAP)
  75. //  or "Next" on one of the custom AppWizard's steps.
  76. $$ENDIF //!CUSTOMTYPE_ZAP
  77. CAppWizStepDlg* C$$Safe_root$$AppWiz::Next(CAppWizStepDlg* pDlg)
  78. {
  79. $$IF(CUSTOMTYPE_ZAP)
  80.     ASSERT(pDlg == NULL);   // By default, this custom AppWizard has no steps
  81.  
  82.     // Set template macros based on the project name entered by the user.
  83.  
  84.     // Get value of $$$$root$$$$ (already set by AppWizard)
  85.     CString strRoot;
  86.     m_Dictionary.Lookup(_T("root"), strRoot);
  87.  
  88.     // Set value of $$$$Doc$$$$, $$$$DOC$$$$
  89.     CString strDoc = strRoot.Left(6);
  90.     m_Dictionary[_T("Doc")] = strDoc;
  91.     strDoc.MakeUpper();
  92.     m_Dictionary[_T("DOC")] = strDoc;
  93.  
  94.     // Set value of $$$$MAC_TYPE$$$$
  95.     strRoot = strRoot.Left(4);
  96.     int nLen = strRoot.GetLength();
  97.     if (strRoot.GetLength() < 4)
  98.     {
  99.         CString strPad(_T(' '), 4 - nLen);
  100.         strRoot += strPad;
  101.     }
  102.     strRoot.MakeUpper();
  103.     m_Dictionary[_T("MAC_TYPE")] = strRoot;
  104.  
  105.     // Return NULL to indicate there are no more steps.  (In this case, there are
  106.     //  no steps at all.)
  107.     return NULL;
  108. $$ELIF(HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE)
  109.     // Delegate to the dialog chooser
  110.     return m_pChooser->Next(pDlg);
  111. $$ELSE
  112.     return NULL;
  113. $$ENDIF //CUSTOMTYPE_ZAP/HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE
  114. }
  115. $$IF(HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE)
  116.  
  117. // This is called when the user clicks "Back" on one of the custom
  118. //  AppWizard's steps.
  119. CAppWizStepDlg* C$$Safe_root$$AppWiz::Back(CAppWizStepDlg* pDlg)
  120. {
  121.     // Delegate to the dialog chooser
  122.     return m_pChooser->Back(pDlg);
  123. }
  124. $$ENDIF //HAS_NEW_STEPS || CUSTOMTYPE_SEQUENCE
  125.  
  126. void C$$Safe_root$$AppWiz::CustomizeProject(IBuildProject* pProject)
  127. {
  128.     // TODO: Add code here to customize the project.  If you don't wish
  129.     //  to customize project, you may remove this virtual override.
  130.  
  131.     // This is called immediately after the default Debug and Release
  132.     //  configurations have been created for each platform.  You may customize
  133.     //  existing configurations on this project by using the methods
  134.     //  of IBuildProject and IConfiguration such as AddToolSettings,
  135.     //  RemoveToolSettings, and AddCustomBuildStep. These are documented in
  136.     //  the Developer Studio object model documentation.
  137.  
  138.     // WARNING!!  IBuildProject and all interfaces you can get from it are OLE
  139.     //  COM interfaces.  You must be careful to release all new interfaces
  140.     //  you acquire.  In accordance with the standard rules of COM, you must
  141.     //  NOT release pProject, unless you explicitly AddRef it, since pProject
  142.     //  is passed as an "in" parameter to this function.  See the documentation
  143.     //  on CCustomAppWiz::CustomizeProject for more information.
  144. }
  145.  
  146.  
  147. // Here we define one instance of the C$$Safe_root$$AppWiz class.  You can access
  148. //  m_Dictionary and any other public members of this class through the
  149. //  global $$safe_root$$aw.
  150. C$$Safe_root$$AppWiz $$safe_root$$aw;
  151.