home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / common / msdev98 / template / atl / addatl.ctl < prev    next >
Encoding:
Text File  |  1998-06-16  |  9.1 KB  |  208 lines

  1. [!Debug()]
  2. [!newguid(TypelibGUID)]
  3.  
  4. [!AddSymbolToString(MIDLHeader, "\"", ProjectName)]
  5. [!AddStringToSymbol(MIDLHeader, MIDLHeader, "_i.h\"")]
  6.  
  7. [!AddSymbolToString(MIDLC, "\"", ProjectName)]
  8. [!AddStringToSymbol(MIDLC, MIDLC, "_i.c\"")]
  9.  
  10. [!if!(ProjectNameHeader)]
  11. [!AddStringToSymbol(ProjectNameHeader, ProjectName, ".h")]
  12. [!endif]
  13.  
  14. [!if!(ProjectNameCPP)]
  15. [!AddStringToSymbol(ProjectNameCPP, ProjectName, ".cpp")]
  16. [!endif]
  17.  
  18.  
  19. [!set(INITGUIDH, "<initguid.h>")]
  20.  
  21. [!AddIncludeFile(ProjectNameHeader,  MIDLHeader)]
  22. [!AddIncludeFile(ProjectNameCPP,  INITGUIDH)]
  23. [!AddIncludeFile(ProjectNameCPP,  MIDLC)]
  24.  
  25. [!AddStringToSymbol(stdafxinclude, GalleryPath, "aatlsdt.h")]
  26. [!AddStringToSymbol(stdafxcpptemplate, GalleryPath, "aatlsdt.cpp")]
  27. [!if!(STDAFXCPP)]
  28. [!AddStringToSymbol(STDAFXCPP, ProjectDirectory, "stdafx.cpp")]
  29. [!endif]
  30. [!AddStringToSymbol(IDLTemplate, GalleryPath, "addatl.idl")]
  31. [!AddStringToSymbol(RGSTemplate, GalleryPath, "addatl.rgs")]
  32. [!AddSymbolToSymbol(RGSName, ProjectDirectory, ProjectName)]
  33. [!AddStringToSymbol(RGSName, RGSName, ".rgs")]
  34. [!strcpy(UpperProjectNameSafe, ProjectNameSafe)]
  35. [!toupper(UpperProjectNameSafe)]
  36. [!AddSymbolToString(IDR_REGISTRYID, "IDR_", UpperProjectNameSafe)]
  37.  
  38. [!if=(MFCCTL, "0")]
  39. [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "AfxOleInit", MFCOLE)]
  40. [!else]
  41. [!set(MFCOLE, "1")]
  42. [!endif]
  43.  
  44.  
  45. [!if!(ProjectHadIDL)]
  46.     [!AddStringToSymbol(IDLProject, ProjectName, ".idl")]
  47.     [!target(IDLProject)]
  48.     [!include(IDLTemplate)]
  49.     [!target()]
  50.     [!AddFileToProject(IDLProject)]
  51. [!endif]
  52.  
  53. [!newguid(AppIDGUID)]
  54.  
  55. [!target(RGSName)]
  56. [!include(RGSTemplate)]
  57. [!target()]
  58. [!AddRegistryToRC(RGSName, IDR_REGISTRYID)]
  59.  
  60.  
  61. [!target(STDAFXH)]
  62.     [!include(stdafxinclude)]
  63. [!target()]
  64.  
  65. [!target(STDAFXCPP)]
  66.     [!include(stdafxcpptemplate)]
  67. [!target()]
  68.  
  69. [!if=(ProjectType, "EXE")]
  70.     [!AddStringToSymbol(projectheadertemplate, GalleryPath, "aatlproj.h")]
  71.     [!AddStringToSymbol(projectcpptemplate, GalleryPath, "aatlproj.cpp")]
  72.  
  73.  
  74.     [!AddMemberVariable(CWinApp, "m_bATLInited", "BOOL", "ACCESS_PRIVATE", "1", ATLINITED)]
  75.  
  76.     [!ExistsMemberFunction(CWinApp, "int ExitInstance()", ExitInstance)]
  77.  
  78.     [!if=(ExitInstance, "1")]
  79.         [!AddToMemberFunction(CWinApp, "int ExitInstance()", projectcpptemplate, InsertIntoExitInstance, BEFORESEARCH, "CWinApp::ExitInstance", )]
  80.     [!else]
  81.         [!AddMemberFunction(CWinApp, "ExitInstance", "virtual int", "", "ACCESS_PUBLIC", projectcpptemplate, 1, AddExitInstance)]
  82.     [!endif]
  83.  
  84.     [!RemoveSymbol("ExitInstance")]
  85.  
  86.     [!AddMemberFunction(CWinApp, "InitATL", "BOOL", "", "ACCESS_PRIVATE", projectcpptemplate, 0, INITATL, BEFORESEARCH)]
  87.  
  88.     [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "AfxEnableControlContainer();", ACTIVEXCTLSUPPORT)]
  89.     [!if=(ACTIVEXCTLSUPPORT, "1")]
  90.         [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertInInitInstance, BEFORESEARCH, "AfxEnableControlContainer")]
  91.     [!else]
  92.         [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertInInitInstance, BEGIN)]
  93.     [!endif]
  94.  
  95.     [!if=(MFCOLE, "0")]
  96.         [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "ParseCommandLine(cmdInfo);", PARSECOMMANDINFO)]
  97.         [!if=(PARSECOMMANDINFO, "0")]
  98.             [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "AfxEnableControlContainer();", AFXENABLECONTROLCONTAINER)]
  99.             [!if=(AFXENABLECONTROLCONTAINER, "0")]
  100.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertAfterAfxEnableControlContainer, BEGIN)]
  101.             [!else]
  102.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertAfterAfxEnableControlContainer, AFTERSEARCH, "AfxEnableControlContainer();")]
  103.             [!endif]
  104.         [!else]
  105.             [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertAfterParseCommand, AFTERSEARCH, "ParseCommandLine(cmdInfo);")]
  106.         [!endif]
  107.  
  108.     [!else]
  109.         [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "COleTemplateServer::RegisterAll();", REGISTERALL)]
  110.         [!if=(REGISTERALL, "1")]
  111.             [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, REGCLASSOBJ, AFTERSEARCH, "COleTemplateServer::RegisterAll();")]
  112.         [!else]
  113.             [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "AfxEnableControlContainer();", AFXENABLECONTROLCONTAINER)]
  114.             [!if=(AFXENABLECONTROLCONTAINER, "0")]
  115.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, REGCLASSOBJ, BEGIN)]
  116.             [!else]
  117.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, REGCLASSOBJ, AFTERSEARCH, "AfxEnableControlContainer();")]
  118.             [!endif]
  119.         [!endif]
  120.  
  121.         [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)", CMDINFO)]
  122.         [!if=(CMDINFO, "0")]
  123.             [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "ParseCommandLine(cmdInfo);", PARSECOMMANDINFO)]
  124.             [!if=(PARSECOMMANDINFO, "1")]
  125.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, IFOLE, AFTERSEARCH, "ParseCommandLine(cmdInfo);")]
  126.             [!endif]
  127.         [!endif]
  128.  
  129.         [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "m_server.UpdateRegistry(OAT_INPLACE_SERVER);", UPDATEREGISTRY)]
  130.         [!if=(UPDATEREGISTRY, "1")]
  131.             [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, REGSVR, AFTERSEARCH, "m_server.UpdateRegistry(OAT_INPLACE_SERVER);")]
  132.         [!else]
  133.             [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "ParseCommandLine(cmdInfo);", PARSECOMMANDINFO)]
  134.             [!if=(PARSECOMMANDINFO, "1")]
  135.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, REGSVR, AFTERSEARCH, "ParseCommandLine(cmdInfo);")]
  136.             [!endif]
  137.         [!endif]
  138.  
  139.     [!endif]
  140.  
  141. [!else] 
  142.     [!AddStringToSymbol(projectheadertemplate, GalleryPath, "aatldll.h")]
  143.     [!AddStringToSymbol(projectcpptemplate, GalleryPath, "aatldll.cpp")]
  144.  
  145.     [!if=(MFCCTL, "1")]
  146.         [!comment (// MFC ActiveX Control)]
  147.         [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertIntoInitInstance, AFTERSEARCH, "COleControlModule::InitInstance")]
  148.         [!AddToMemberFunction(CWinApp, "int ExitInstance()", projectcpptemplate, InsertIntoExitInstance, BEFORESEARCH, "COleControlModule::ExitInstance()")]
  149.         [!AddToMemberFunction(NULLSTR, "STDAPI DllRegisterServer(void)", projectcpptemplate, InsertInDllRegisterServer, BEFORESEARCH, "return NOERROR")]
  150.         [!AddToMemberFunction(NULLSTR, "STDAPI DllUnregisterServer()", projectcpptemplate, InsertInDllUnregisterServer, BEFORESEARCH, "return NOERROR")]
  151.         [!AddMemberFunction(CWinApp, "InitATL", "BOOL", "", "ACCESS_PRIVATE", projectcpptemplate, 0, INITATL, BEFORESEARCH)]
  152.     [!else]
  153.         [!if=(MFCCTL, "0")]
  154.         [!ExistsInMemberFunction(CWinApp, "BOOL InitInstance()", "COleObjectFactory::RegisterAll();", MFCOLE)]
  155.         [!endif]
  156.  
  157.         [!if=(MFCOLE, "1")]
  158.             [!comment (// MFC Regular DLL with Automation)]
  159.             [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertIntoInitInstance, AFTERSEARCH, "COleObjectFactory::RegisterAll();")]
  160.  
  161.             [!ExistsMemberFunction(CWinApp, "int ExitInstance()", ExitInstance)]
  162.  
  163.             [!if=(ExitInstance, "1")]
  164.                 [!AddToMemberFunction(CWinApp, "int ExitInstance()", projectcpptemplate, InsertIntoExitInstance, BEFORESEARCH, "CWinApp::ExitInstance", )]
  165.             [!else]
  166.                 [!AddMemberFunction(CWinApp, "ExitInstance", "virtual int", "", "ACCESS_PUBLIC", projectcpptemplate, 1, AddExitInstance)]
  167.             [!endif]
  168.             [!RemoveSymbol("ExitInstance")]
  169.  
  170.  
  171.             [!AddToMemberFunction(NULLSTR, "STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)", projectcpptemplate, InsertInDllGetClassObject, BEFORESEARCH, "AfxDllGetClassObject")]
  172.             [!AddToMemberFunction(NULLSTR, "STDAPI DllCanUnloadNow()", projectcpptemplate, InsertInDllCanUnloadNow, BEFORESEARCH, "AfxDllCanUnloadNow()")]
  173.             [!AddToMemberFunction(NULLSTR, "STDAPI DllRegisterServer()", projectcpptemplate, InsertInDllRegisterServer, AFTERSEARCH, "COleObjectFactory::UpdateRegistryAll()")]
  174.             [!AddMemberFunction(CWinApp, "InitATL", "BOOL", "", "ACCESS_PRIVATE", projectcpptemplate, 0, INITATL, BEFORESEARCH)]
  175.         [!else]
  176.             [!ExistsMemberFunction(CWinApp, "BOOL InitInstance()", InitInstance)]
  177.  
  178.             [!if=(InitInstance, "1")]
  179.                 [!AddToMemberFunction(CWinApp, "BOOL InitInstance()", projectcpptemplate, InsertIntoInitInstance, BEFORESEARCH, "CWinApp::InitInstance", )]
  180.             [!else]
  181.                 [!AddMemberFunction(CWinApp, "InitInstance", "virtual BOOL", "", "ACCESS_PUBLIC", projectcpptemplate, 1, AddInitInstance)]
  182.             [!endif]
  183.             [!RemoveSymbol("InitInstance")]
  184.  
  185.             [!ExistsMemberFunction(CWinApp, "int ExitInstance()", ExitInstance)]
  186.  
  187.             [!if=(ExitInstance, "1")]
  188.                 [!AddToMemberFunction(CWinApp, "int ExitInstance()", projectcpptemplate, InsertIntoExitInstance, BEFORESEARCH, "CWinApp::ExitInstance", )]
  189.             [!else]
  190.                 [!AddMemberFunction(CWinApp, "ExitInstance", "virtual int", "", "ACCESS_PUBLIC", projectcpptemplate, 1, AddExitInstance)]
  191.             [!endif]
  192.             [!RemoveSymbol("ExitInstance")]
  193.  
  194.             [!AddMemberFunction(CWinApp, "InitATL", "BOOL", "", "ACCESS_PRIVATE", projectcpptemplate, 0, INITATL, BEFORESEARCH)]
  195.         [!endif]
  196.     [!endif]
  197. [!endif]
  198.  
  199. [!set(InsertAfterApp, "1")]
  200.  
  201. [!target(ProjectNameCPP)]
  202.     [!include(projectcpptemplate)]
  203. [!target()]
  204.  
  205. [!RemoveSymbol(InsertAfterApp)]
  206.  
  207. [!Commit()]
  208. [!IDLSettingsForATL()]