如何解决CWindowImpl 是否使用 CRTP 来调用 Windows 过程?
我的印象是,为了使用奇怪的重复模板模式,必须将 this
指针静态向下转换为派生类。
但在 CWindowImplBaseT
中,ProcessWindowMessage
的调用方式如下:
template <class TBase,class TWinTraits>
LRESULT CALLBACK CWindowImplBaseT< TBase,TWinTraits >::WindowProc(
_In_ HWND hWnd,_In_ UINT uMsg,_In_ WPARAM wParam,_In_ LPARAM lParam)
{
CWindowImplBaseT< TBase,TWinTraits >* pThis = (CWindowImplBaseT< TBase,TWinTraits >*)hWnd;
// set a ptr to this message and save the old value
_ATL_MSG msg(pThis->m_hWnd,uMsg,wParam,lParam);
const _ATL_MSG* pOldMsg = pThis->m_pCurrentMsg;
pThis->m_pCurrentMsg = &msg;
// pass to the message map to process
LRESULT lRes = 0;
BOOL bRet = pThis->ProcessWindowMessage(pThis->m_hWnd,lParam,lRes,0);
//. . .
}
似乎没有任何静态转换到应用程序声明的派生类(由 CWindowImpl
中的模板提供)。那么这是否意味着该课程没有获得优势或 CRTP?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。