staticLRESULTCALLBACKStartWindowProc(HWNDhWnd,UINTuMsg,WPARAMwParam,LPARAMlParam){CContainedWindowT<TBase>*pThis=(CContainedWindowT<TBase>*)_Module.ExtractCreateWndData();ATLASSERT(pThis!=NULL);pThis->m_hWnd=hWnd;pThis->m_thunk.Init(WindowProc,pThis);WNDPROCpProc=(WNDPROC)&(pThis->m_thunk.thunk);WNDPROCpOldProc=(WNDPROC)::SetWindowLong(hWnd,GWL_WNDPROC,(LONG)pProc);#ifdef_DEBUG//checkifsomebodyhassubclassedusalreadysincewediscardit
if(pOldProc!=StartWindowProc)ATLTRACE2(atlTraceWindowing,0,_T("Subclassingthroughahookdiscarded.\n"));#elsepOldProc;//avoidunusedwarning
#endifreturnpProc(hWnd,uMsg,wParam,lParam);}
class CWndProcThunk
{
public:
union
{
_AtlCreateWndData cd;
_WndProcThunk thunk;
};
void Init(WNDPROC proc, void* pThis)
{
#if defined (_M_IX86)
thunk.m_mov = 0x042444C7; //C7 44 24 0C
thunk.m_this = (DWORD)pThis;
thunk.m_jmp = 0xe9;
thunk.m_relproc = (int)proc - ((int)this+sizeof(_WndProcThunk));
#elif defined (_M_ALPHA)
thunk.ldah_at = (0x279f0000 | HIWORD(proc)) + (LOWORD(proc)>>15);
thunk.ldah_a0 = (0x261f0000 | HIWORD(pThis)) + (LOWORD(pThis)>>15);
thunk.lda_at = 0x239c0000 | LOWORD(proc);
thunk.lda_a0 = 0x22100000 | LOWORD(pThis);
thunk.jmp = 0x6bfc0000;
#endif
// write block from data cache and
// flush from instruction cache
FlushInstructionCache(GetCurrentProcess(), &thunk, sizeof(thunk));
}
};
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CContainedWindowT< TBase >* pThis = (CContainedWindowT< TBase >*)hWnd;
ATLASSERT(pThis->m_hWnd != NULL);
ATLASSERT(pThis->m_pObject != NULL);
// set a ptr to this message and save the old value
MSG msg = { pThis->m_hWnd, uMsg, wParam, lParam, 0, { 0, 0 } };
const MSG* pOldMsg = pThis->m_pCurrentMsg;
pThis->m_pCurrentMsg = &msg;
// pass to the message map to process
LRESULT lRes;
BOOL bRet = pThis->m_pObject->ProcessWindowMessage(pThis->m_hWnd, uMsg, wParam, lParam, lRes, pThis->m_dwMsgMapID);
// restore saved value for the current message
ATLASSERT(pThis->m_pCurrentMsg == &msg);
pThis->m_pCurrentMsg = pOldMsg;
// do the default processing if message was not handled
if(!bRet)
{
if(uMsg != WM_NCDESTROY)
lRes = pThis->DefWindowProc(uMsg, wParam, lParam);
else
{
// unsubclass, if needed
LONG pfnWndProc = ::GetWindowLong(pThis->m_hWnd, GWL_WNDPROC);
lRes = pThis->DefWindowProc(uMsg, wParam, lParam);
if(pThis->m_pfnSuperWindowProc != ::DefWindowProc && ::GetWindowLong(pThis->m_hWnd, GWL_WNDPROC) == pfnWndProc)
::SetWindowLong(pThis->m_hWnd, GWL_WNDPROC, (LONG)pThis->m_pfnSuperWindowProc);
// clear out window handle
pThis->m_hWnd = NULL;
}
}
return lRes;
}
相关推荐
atl开发指南源代码 只有源代码,不包括书籍
两个 ATL COM 组件源代码参考例子
手写ATLCOM组件示例代码,手写ATLCOM组件示例代码
《Atl编程指南》 所附源码,里面包括所有的例子
2013年最新二维码开发(ATL)源程序代码,VS2005开发,是C#工具开发二维条码应用最理想的参考范例。提供ATL插件接口开发方法,条码图像打印、条码参数设置和非托管API调用方法,并教您如何将图像、声音和指纹压缩放入...
ATL里实现COM的组合与聚合,有代码和文字图片说明
《ATL开发指南》随书代码
ATL框架库,用于编译器,下有ATL中的头文件,库文件,相关实现代码,直接放置到开发环境下即可。
使用atl开发word插件,支持robbin工具条。开发环境:vs2012
ATL开发指南的例程的源代码,有助于学习。
《ATL开发指南(第二版)》源代码 《ATL开发指南(第二版)》源代码
清晰pdf ,这是第二部分。 ATL的发明人Jim Springfield亲自作序推荐 ...全书内容丰富,深入浅出,主要涵盖了ATL内部架构和实现方法、运用向导简化ATL开发、C++/COM/ATL中字符串的使用技巧、理解并正确实现IUnknown、
AtlServer.zip webserver中用到的东西 有需要的下载
NULL 博文链接:https://leng.iteye.com/blog/1685871
在VS2008中移除了对ATL Server的内置代码,而是把它独立为一个开源项目,见 http://www.codeplex.com/AtlServer/ 但这意味着原来在vs2003,vs2005程序中使用了以下头文件的程序将编译出错, 如 fatal...
collection.zip:包含VC Atl开发的集合的源代码(组件程序和测试程序) enum.zip:包含VC Atl开发的枚举器的源代码(组件程序和测试程序) event.zip:包含VC Atl开发的事件的源代码(组件程序和测试程序) win....
ATL Internals源代码
ATL Internals源代码
ATL窗口代码 写的不错
atl开发指南 图书加源代码 atl开发指南 图书加源代码