COMMANDS.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:3k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // Commands.h : header file
  2. //
  3. #if !defined(AFX_COMMANDS_H__36FDE876_EA61_11D0_B595_00A0C91BC942__INCLUDED_)
  4. #define AFX_COMMANDS_H__36FDE876_EA61_11D0_B595_00A0C91BC942__INCLUDED_
  5. #include "bldrecTypes.h"
  6. class CCommands : 
  7. public CComDualImpl<ICommands, &IID_ICommands, &LIBID_Bldrec>, 
  8. public CComObjectRoot,
  9. public CComCoClass<CCommands, &CLSID_Commands>
  10. {
  11. protected:
  12. IApplication* m_pApplication;
  13. public:
  14. CCommands();
  15. ~CCommands();
  16. void SetApplicationObject(IApplication* m_pApplication);
  17. IApplication* GetApplicationObject() { return m_pApplication; }
  18. void UnadviseFromEvents();
  19. BEGIN_COM_MAP(CCommands)
  20. COM_INTERFACE_ENTRY(IDispatch)
  21. COM_INTERFACE_ENTRY(ICommands)
  22. END_COM_MAP()
  23. DECLARE_NOT_AGGREGATABLE(CCommands)
  24. protected:
  25. CString m_strFile;
  26. // This class template is used as the base class for the Application
  27. //  event handler object and the Debugger event handler object,
  28. //  which are declared below.
  29. template <class IEvents, const IID* piidEvents, const GUID* plibid,
  30. class XEvents, const CLSID* pClsidEvents>
  31. class XEventHandler :
  32. public CComDualImpl<IEvents, piidEvents, plibid>,
  33. public CComObjectRoot,
  34. public CComCoClass<XEvents, pClsidEvents>
  35. {
  36. public:
  37. BEGIN_COM_MAP(XEvents)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. COM_INTERFACE_ENTRY_IID(*piidEvents, IEvents)
  40. END_COM_MAP()
  41. DECLARE_NOT_AGGREGATABLE(XEvents)
  42. void Connect(IUnknown* pUnk)
  43. { VERIFY(SUCCEEDED(AtlAdvise(pUnk, this, *piidEvents, &m_dwAdvise))); }
  44. void Disconnect(IUnknown* pUnk)
  45. { AtlUnadvise(pUnk, *piidEvents, m_dwAdvise); }
  46. CCommands* m_pCommands;
  47. protected:
  48. DWORD m_dwAdvise;
  49. };
  50. // This object handles events fired by the Application object
  51. class XApplicationEvents : public XEventHandler<IApplicationEvents, 
  52. &IID_IApplicationEvents, &LIBID_Bldrec, 
  53. XApplicationEvents, &CLSID_ApplicationEvents>
  54. {
  55. public:
  56. // IApplicationEvents methods
  57. STDMETHOD(BeforeBuildStart)(THIS);
  58. STDMETHOD(BuildFinish)(THIS_ long nNumErrors, long nNumWarnings);
  59. STDMETHOD(BeforeApplicationShutDown)(THIS);
  60. STDMETHOD(DocumentOpen)(THIS_ IDispatch * theDocument);
  61. STDMETHOD(BeforeDocumentClose)(THIS_ IDispatch * theDocument);
  62. STDMETHOD(DocumentSave)(THIS_ IDispatch * theDocument);
  63. STDMETHOD(NewDocument)(THIS_ IDispatch * theDocument);
  64. STDMETHOD(WindowActivate)(THIS_ IDispatch * theWindow);
  65. STDMETHOD(WindowDeactivate)(THIS_ IDispatch * theWindow);
  66. STDMETHOD(WorkspaceOpen)(THIS);
  67. STDMETHOD(WorkspaceClose)(THIS);
  68. STDMETHOD(NewWorkspace)(THIS);
  69. };
  70. typedef CComObject<XApplicationEvents> XApplicationEventsObj;
  71. XApplicationEventsObj* m_pApplicationEventsObj;
  72. // This object handles events fired by the Application object
  73. class XDebuggerEvents : public XEventHandler<IDebuggerEvents, 
  74. &IID_IDebuggerEvents, &LIBID_Bldrec, 
  75. XDebuggerEvents, &CLSID_DebuggerEvents>
  76. {
  77. public:
  78. // IDebuggerEvents method
  79.     STDMETHOD(BreakpointHit)(THIS_ IDispatch * pBreakpoint);
  80. };
  81. typedef CComObject<XDebuggerEvents> XDebuggerEventsObj;
  82. XDebuggerEventsObj* m_pDebuggerEventsObj;
  83. public:
  84. BOOL SaveFileName();
  85. CTime m_theLastTime;
  86. BOOL MarkTime(LPCSTR szItem, BOOL fStart);
  87. // ICommands methods
  88. STDMETHOD(BldrecCommandMethod)(THIS);
  89. };
  90. typedef CComObject<CCommands> CCommandsObj;
  91. //{{AFX_INSERT_LOCATION}}
  92. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  93. #endif // !defined(AFX_COMMANDS_H__36FDE876_EA61_11D0_B595_00A0C91BC942__INCLUDED)