home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / autobld / commands.h < prev    next >
C/C++ Source or Header  |  1998-04-02  |  4KB  |  125 lines

  1. // Commands.h : header file
  2. //
  3.  
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6.  
  7. #if !defined(AFX_COMMANDS_H__D93F3A18_3DA9_11D0_B889_00C04FD7A0F0__INCLUDED_)
  8. #define AFX_COMMANDS_H__D93F3A18_3DA9_11D0_B889_00C04FD7A0F0__INCLUDED_
  9.  
  10. #include "AutoBldTypes.h"
  11.  
  12. class CCommands :
  13.     public CComDualImpl<ICommands, &IID_ICommands, &LIBID_AutoBld>,
  14.     public CComObjectRoot,
  15.     public CComCoClass<CCommands, &CLSID_Commands>
  16. {
  17. protected:
  18.     IApplication* m_pApplication;
  19.  
  20. public:
  21.     CCommands();
  22.     ~CCommands();
  23.     void SetApplicationObject(IApplication* m_pApplication);
  24.     IApplication* GetApplicationObject() { return m_pApplication; }
  25.     void UnadviseFromEvents();
  26.  
  27.     BEGIN_COM_MAP(CCommands)
  28.         COM_INTERFACE_ENTRY(IDispatch)
  29.         COM_INTERFACE_ENTRY(ICommands)
  30.     END_COM_MAP()
  31.     DECLARE_NOT_AGGREGATABLE(CCommands)
  32.  
  33.     BOOL m_bTesting;
  34.     int m_nTotalWarnings;
  35.     int m_nTotalErrors;
  36.     CString m_strFileToSend;
  37.     CString m_strStatusLine;
  38.     CString m_strSendTo;
  39.     BOOL m_bCloseWhenDone;
  40.     BOOL m_bMailOnEach;
  41.     BOOL m_bSendFile;
  42.     BOOL m_bIncBuildResults;
  43.     BOOL m_bSendMail;
  44.     CString m_strBuildingConfigurationName;
  45.     BOOL m_bAutoBuilding;
  46.     BOOL m_bBuildInProgres;
  47.  
  48. protected:
  49.     // This class template is used as the base class for the Application
  50.     //  event handler object and the Debugger event handler object,
  51.     //  which are declared below.
  52.     template <class IEvents, const IID* piidEvents, const GUID* plibid,
  53.         class XEvents, const CLSID* pClsidEvents>
  54.     class XEventHandler :
  55.         public CComDualImpl<IEvents, piidEvents, plibid>,
  56.         public CComObjectRoot,
  57.         public CComCoClass<XEvents, pClsidEvents>
  58.     {
  59.     public:
  60.         BEGIN_COM_MAP(XEvents)
  61.             COM_INTERFACE_ENTRY(IDispatch)
  62.             COM_INTERFACE_ENTRY_IID(*piidEvents, IEvents)
  63.         END_COM_MAP()
  64.         DECLARE_NOT_AGGREGATABLE(XEvents)
  65.         void Connect(IUnknown* pUnk)
  66.         { VERIFY(SUCCEEDED(AtlAdvise(pUnk, this, *piidEvents, &m_dwAdvise))); }
  67.         void Disconnect(IUnknown* pUnk)
  68.         { AtlUnadvise(pUnk, *piidEvents, m_dwAdvise); }
  69.  
  70.         CCommands* m_pCommands;
  71.  
  72.     protected:
  73.         DWORD m_dwAdvise;
  74.     };
  75.  
  76.     // This object handles events fired by the Application object
  77.     class XApplicationEvents : public XEventHandler<IApplicationEvents,
  78.         &IID_IApplicationEvents, &LIBID_AutoBld,
  79.         XApplicationEvents, &CLSID_ApplicationEvents>
  80.     {
  81.     public:
  82.         // IApplicationEvents methods
  83.         STDMETHOD(BeforeBuildStart)(THIS);
  84.         STDMETHOD(BuildFinish)(THIS_ long nNumErrors, long nNumWarnings);
  85.         STDMETHOD(BeforeApplicationShutDown)(THIS);
  86.         STDMETHOD(DocumentOpen)(THIS_ IDispatch * theDocument);
  87.         STDMETHOD(BeforeDocumentClose)(THIS_ IDispatch * theDocument);
  88.         STDMETHOD(DocumentSave)(THIS_ IDispatch * theDocument);
  89.         STDMETHOD(NewDocument)(THIS_ IDispatch * theDocument);
  90.         STDMETHOD(WindowActivate)(THIS_ IDispatch * theWindow);
  91.         STDMETHOD(WindowDeactivate)(THIS_ IDispatch * theWindow);
  92.         STDMETHOD(WorkspaceOpen)(THIS);
  93.         STDMETHOD(WorkspaceClose)(THIS);
  94.         STDMETHOD(NewWorkspace)(THIS);
  95.     };
  96.     typedef CComObject<XApplicationEvents> XApplicationEventsObj;
  97.  
  98.     XApplicationEventsObj* m_pApplicationEventsObj;
  99.  
  100.     // This object handles events fired by the Application object
  101.     class XDebuggerEvents : public XEventHandler<IDebuggerEvents,
  102.         &IID_IDebuggerEvents, &LIBID_AutoBld,
  103.         XDebuggerEvents, &CLSID_DebuggerEvents>
  104.     {
  105.     public:
  106.         // IDebuggerEvents method
  107.         STDMETHOD(BreakpointHit)(THIS_ IDispatch * pBreakpoint);
  108.     };
  109.     typedef CComObject<XDebuggerEvents> XDebuggerEventsObj;
  110.     XDebuggerEventsObj* m_pDebuggerEventsObj;
  111.  
  112. public:
  113. // ICommands methods
  114.     STDMETHOD(AutoBuildTest)(THIS);
  115.     STDMETHOD(AutoBuild)(THIS);
  116.     STDMETHOD(AutoBuildConfigure)(THIS);
  117. };
  118.  
  119. typedef CComObject<CCommands> CCommandsObj;
  120.  
  121. //{{AFX_INSERT_LOCATION}}
  122. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  123.  
  124. #endif // !defined(AFX_COMMANDS_H__D93F3A18_3DA9_11D0_B889_00C04FD7A0F0__INCLUDED)
  125.