|
#ifndef ESB_EventHandler_H
#define ESB_EventHandler_H
#include "ComHelper.h"
//_ATL_IIDOF();
class ESBDSAddinImpl;
template <class IEvents,const GUID* plibid, class XEvents, const CLSID* pClsidEvents>
class XEventHandler : public CComDualImpl<IEvents, &__uuidof(IEvents), plibid>,
public CComObjectRoot,
public CComCoClass<XEvents, pClsidEvents>
{
private:
//CComPtr<IApplication> mApplication;
ESBDSAddinImpl *mAddin;
public :
XEventHandler() : mAddin(NULL) {}
void setAddIn(ESBDSAddinImpl *addin)
{
if(mAddin != NULL)
{
Disconnect(mAddin->getApplication());
}
mAddin = addin;
Connect(mAddin->getApplication());
}
ESBDSAddinImpl* getAddIn()
{ return mAddin; }
void Connect(IUnknown* pUnk)
{ cex_ = AtlAdvise(pUnk, this, __uuidof(IEvents), &mCookie); }
void Disconnect(IUnknown* pUnk)
{ AtlUnadvise(pUnk, __uuidof(IEvents), mCookie); }
public:
BEGIN_COM_MAP(XEvents)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY_IID(__uuidof(IEvents), IEvents)
END_COM_MAP()
DECLARE_NOT_AGGREGATABLE(XEvents)
protected:
DWORD mCookie;
};
// object handles events fired by the Application object
class ApplicationEventHandler : public XEventHandler<IApplicationEvents, &LIBID_ESBDSADDINLib,
ApplicationEventHandler, &CLSID_ApplicationEvents>
{
//CComPtr<IESBServer> getESBServer();
public:
// IApplicationEvents methods
HResult BeforeBuildStart();
HResult BuildFinish(long nNumErrors, long nNumWarnings);
HResult BeforeApplicationShutDown();
HResult DocumentOpen(IDispatch * theDocument);
HResult BeforeDocumentClose(IDispatch * theDocument);
HResult DocumentSave(IDispatch * theDocument);
HResult NewDocument(IDispatch * theDocument);
HResult WindowActivate(IDispatch * theWindow);
HResult WindowDeactivate(IDispatch * theWindow);
HResult WorkspaceOpen();
HResult WorkspaceClose();
HResult NewWorkspace();
};
/*
class DebuggerEventHandler : public XEventHandler<IDebuggerEvents,
&IID_IDebuggerEvents, &LIBID_ESBDSADDINLib,
DebuggerEventHandler, &CLSID_DebuggerEvents>
{
public:
// IDebuggerEvents method
HResult BreakpointHit( IDispatch * pBreakpoint);
};
*/
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.