-
2009-07-07
事件处理
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://xingzhesun.blogbus.com/logs/42018951.html
#pragma once
#include <atlstr.h>
class CUccEvent;
class CUccEventHandler
{
public:
CUccEventHandler(){};
virtual ~CUccEventHandler(){};
public:
virtual bool Do(LPCTSTR lpMsg) = 0{};
};class CUccEvent
{
public:
CUccEvent(void):m_pEventHder(NULL){}CUccEvent(CUccEventHandler* pEventHder){
m_pEventHder = pEventHder;
}virtual ~CUccEvent(void){
m_pEventHder = NULL;
}public:
void Attach(const CUccEventHandler* pEventHder){
m_pEventHder = (CUccEventHandler*)pEventHder;
}CUccEventHandler* Detach(void){
CUccEventHandler* pTemp = m_pEventHder;
m_pEventHder = NULL;
return pTemp;
}public:
virtual bool Fire(LPCTSTR lpMsg) = 0{
if (NULL != m_pEventHder)
{
return m_pEventHder->Do(lpMsg);
}else{
return FALSE;
}
}
private:
CUccEventHandler* m_pEventHder;
};
class CUccGpEventHandler:public CUccEventHandler
{
public:
CUccGpEventHandler(void){};
virtual ~CUccGpEventHandler(){};
public:
virtual bool Do(LPCTSTR lpMsg)
{
return true;
}
};
class CUccGpEvent:public CUccEvent
{
public:
CUccGpEvent(CUccEventHandler* pEventHder):CUccEvent(pEventHder){};
~CUccGpEvent(){};
public:
virtual bool Fire(LPCTSTR lpMsg){
return CUccEvent::Fire(lpMsg);
}
};随机文章:
怎样检查内存泄漏? 2009-06-19VC++帧不对齐 2009-06-01AccessibleObjectFromWindow 2009-03-06reference的底层几乎都是以指针来完成的 2009-02-16svn文件目录 2008-08-01
收藏到:Del.icio.us







