请教关于_Module.ExtractCreateWndData()的两个问题!
LRESULT CALLBACK CWindowImplBaseT< TBase, TWinTraits >::StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CWindowImplBaseT< TBase, TWinTraits >* pThis = (CWindowImplBaseT< TBase, TWinTraits >*)_Module.ExtractCreateWndData();
ATLASSERT(pThis != NULL);
pThis->m_hWnd = hWnd;
pThis->m_thunk.Init(pThis->GetWindowProc(), pThis);
...
我有两个问题:
一、pThis是不是派生类对象this指针?若是,为什么要把它转换成
CWindowImplBaseT< TBase, TWinTraits >* ?
二、_Module.ExtractCreateWndData() 能够获取派生类对象的this指针,那就没必要再通过thunk机制把 hWnd 转换成this指针了,直接在窗口函数wndproc中用通过_Module.ExtractCreateWndData()获取this就行了,是不是?