VC2008中AfxGetMainWnd函数的变化
来源:互联网 发布:昆山大数据产业园招聘 编辑:程序博客网 时间:2024/06/02 04:26
今天把一个VC6的旧项目转为VC2008项目,运行后程序挂掉。中断后发现程序挂在工作线程中调用AfxGetMainWnd后,因为AfxGetMainWnd返回了NULL指针,随后导致非法访问。
查看MSDN,发现如下描述:
If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.
AfxGetMainWnd函数在主线程下,返回主窗口指针。在其它线程下,返回当前线程的窗口指针。因为我是在工作线程下调用的AfxGetMainWnd函数,该线程没有创建窗口,所以使该函数返回空指针。
之前使用VC6的时候,在不管在任何线程下AfxGetMainWnd都是返回主窗口的指针。因为一直使用VC6,不知道微软什么时候更改了这个函数的实现。
- VC2008中AfxGetMainWnd函数的变化
- AfxGetMainWnd 函数
- VC2008下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
- 使用AfxGetMainWnd函数的一个心得
- VC2008中CString转换为Char和wchar_t的函数
- afxgetapp->afxmainwnd 与afxgetmainwnd的区别 /线程中调用afxgetmainwnd的问题
- AfxGetMainWnd()函数用法
- AfxGetMainWnd()函数用法
- AfxGetMainWnd()函数用法
- AfxGetMainWnd 函数的一个容易被忽略的说明
- VS2005/VC2008中SetUnhandledExceptionFilter函数无效
- 多线程中AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别?
- 多线程中AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别?
- 关于在线程中使用AfxGetMainWnd()出错的问题
- 在线程中执行AfxGetMainWnd()出错的问题
- python3中range函数的变化
- AfxGetMainWnd()
- VC2008中Vector的erase使用
- innerHTML和outerHTML与innerText和outerText
- 产品、用户
- 大端小端转换
- javascript常用判断写法
- 外贸业务员的辞职报告
- VC2008中AfxGetMainWnd函数的变化
- struts2之整合sitemesh(定义装饰器页面)
- 【转】不要迷失在技术的海洋中
- 2011年
- SQL Server 2008内存性能监控
- JavaScript中如何实现函数参数可变
- 函数指针传递和全局指针的测试
- C#[Serializable]在C#中的作用-NET 中的对象序列化
- 十三个经典算法研究与总结、目录+索引