以下是从MFC中复制的代码.
BOOL CWnd::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
int x, int y, int nWidth, int nHeight,
HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam)
{
// allow modification of several common create parameters
CREATESTRUCT cs;
cs.dwExStyle = dwExStyle;
cs.lpszClass = lpszClassName;
cs.lpszName = lpszWindowName;
cs.style = dwStyle;
cs.x = x;
cs.y = y;
cs.cx = nWidth;
cs.cy = nHeight;
cs.hwndParent = hWndParent;
cs.hMenu = nIDorHMenu;
cs.hInstance = AfxGetInstanceHandle();
cs.lpCreateParams = lpParam; if (!PreCreateWindow(cs))
{
PostNcDestroy();
return FALSE;
} AfxHookWindowCreate(this);
HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);#ifdef _DEBUG
if (hWnd == NULL)
{
TRACE1("Warning: Window creation failed: GetLastError returns 0x%8.8X\n",
GetLastError());
}
#endif if (!AfxUnhookWindowCreate())
PostNcDestroy(); // cleanup if CreateWindowEx fails too soon if (hWnd == NULL)
return FALSE;
ASSERT(hWnd == m_hWnd); // should have been set in send msg hook
return TRUE;
}上面函数的最后:ASSERT(hWnd == m_hWnd); // should have been set in send msg hook
问题:他说m_hWnd被赋值,在发送hook消息的时候. 但是阅读上面代码 ,在创建窗口之后根本没有发送这个消息,唯一可能的地方就是"if (!AfxUnhookWindowCreate())",但是我查看了AfxUnhookWindowCreate()函数,也没有发送过什么消息啊.请高手指点......
BOOL CWnd::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
int x, int y, int nWidth, int nHeight,
HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam)
{
// allow modification of several common create parameters
CREATESTRUCT cs;
cs.dwExStyle = dwExStyle;
cs.lpszClass = lpszClassName;
cs.lpszName = lpszWindowName;
cs.style = dwStyle;
cs.x = x;
cs.y = y;
cs.cx = nWidth;
cs.cy = nHeight;
cs.hwndParent = hWndParent;
cs.hMenu = nIDorHMenu;
cs.hInstance = AfxGetInstanceHandle();
cs.lpCreateParams = lpParam; if (!PreCreateWindow(cs))
{
PostNcDestroy();
return FALSE;
} AfxHookWindowCreate(this);
HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);#ifdef _DEBUG
if (hWnd == NULL)
{
TRACE1("Warning: Window creation failed: GetLastError returns 0x%8.8X\n",
GetLastError());
}
#endif if (!AfxUnhookWindowCreate())
PostNcDestroy(); // cleanup if CreateWindowEx fails too soon if (hWnd == NULL)
return FALSE;
ASSERT(hWnd == m_hWnd); // should have been set in send msg hook
return TRUE;
}上面函数的最后:ASSERT(hWnd == m_hWnd); // should have been set in send msg hook
问题:他说m_hWnd被赋值,在发送hook消息的时候. 但是阅读上面代码 ,在创建窗口之后根本没有发送这个消息,唯一可能的地方就是"if (!AfxUnhookWindowCreate())",但是我查看了AfxUnhookWindowCreate()函数,也没有发送过什么消息啊.请高手指点......
解决方案 »
- 用VC6生成一个EXE时出错
- createFile失败,getlasterror为32,请帮助分析原因
- 在block方式下send会阻塞直到发完所有数据吧?
- 求解vc绘制特效字体的方法,高手请进。
- 局域网游戏通信问题
- 提问:1,有没什么XML文挡解析的好东西 2,如何重用项目设置
- 如何将一个文件夹自动打包成.rar文件发送,,,在接收端自解压还原(传输过程可以省略)...
- 请问我做的一个COM组件,是独立运行的.exe形式的COM服务器,我想在WIN98注册,但在98下注册不了,所有MFC所需的动态库我都已经带上了,请
- 请教:FileLen()函数为什么不能用?
- 关于RichEditctrl显示图片的问题,谢谢
- 希望我的面试能成功。技术关已经过了,现在等老总点头了。当然希望能成,如果不能成,也没有关系。
- 同一程序两次导入同一个动态库
_AfxCbtFilterHook(int code, WPARAM wParam, LPARAM lParam)AfxHookWindowCreate(this);建的就是它
::CreateWindowEx后(前?忘了)先运行倒上面那个函数在里面会有Attach函数,把hWnd和pWnd连续起来,,具体代码楼主加个断点自己看吧