现在的位置: 首页 > 综合 > 正文

用ATL手法来实现接口设计

2012年03月09日 ⁄ 综合 ⁄ 共 864字 ⁄ 字号 评论关闭

给出简单例子,体现一下设计思路

接口:

IPlatform: IUnknown

IView: IPlatform

IPicView: IView

---------------------------------

IContorl: IPlatform

IToolbarCtl: IContorl

=======================================

实现:

/////////////////////////////////////////////////////////////////////////////
// IPlatformImpl
template <class T>
class ATL_NO_VTABLE IPlatformImpl :
public T
{
public:

xxxx // IPlatform 的方法

}

/////////////////////////////////////////////////////////////////////////////
// IViewImpl
template <class T, class I>
class ATL_NO_VTABLE IViewImpl :
public T,
public I

{
 BEGIN_MSG_MAP(IViewImpl)
  MESSAGE_HANDLER(WM_ERASEBKGND , OnEraseBkGnd)
 END_MSG_MAP()
 
 
public:
 DECLARE_WND_CLASS("PLATFORM_VIEW")
 yyyy // IView的方法

}

//////////////////////////////////////////////////////////////////////////////////

class CPicView :
 public IViewImpl< CWindowImpl<CPicView>, IPlatformImpl<IPicView> >,
 public CComObjectRoot,
 public CComCoClass<CPicView>,

 

抱歉!评论已关闭.