VC8下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
来源:互联网 发布:淘宝网二手汽车 编辑:程序博客网 时间:2024/06/07 17:48
一个vc6的项目放到vc8下重新编译 这里死活过不去 查了些资料无果 后来翻到一句老外的回答
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()返回的是和当前线程相关联的窗体句柄而不是当前程序的主窗体句柄。不知道这是不是vc8的一个改变,也没时间去细查。
解决方法1:
CWnd* m_pCWnd = NULL;
在OnInitDialog里 m_pCWnd = AfxGetMainWnd();
解决方法2:
调用AfxGetMainWnd()的地方替换成AfxGetApp()->m_pMainWnd
编译后运行问题解决
转自: http://www.freshbug.com/archives/84
- VC8下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
- VC8下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
- VC2008下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
- 多线程AfxGetMainWnd() 返回空
- 多线程AfxGetMainWnd问题的解决
- getActionBar() 返回空指针问题
- Android新版SDK中findViewById返回空指针问题
- findViewById返回空指针的解决方法
- camera.open()返回空指针的问题
- 多线程下双重检查锁的问题及解决方法
- 多线程下双重检查锁的问题及解决方法
- 指针在子函数中动态分配空间的问题及解决方法
- Android MVVM DataBinding在Fragment onCreateView()中getAdapter()显示空指针的问题的一种解决方法
- vc6到vc8移植问题及处理
- vc6到vc8移植问题及处理
- fopen返回空指针
- Mac环境下eclipse在使用junit的空指针问题
- AfxGetMainWnd 返回值
- 简单的读xml事例 dom4j
- JConsole的使用手册
- Struts2 struts.xml 常用配置信息
- Tomcat shtml ssi
- C# GDI+ 文字操作
- VC8下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法
- 变量的存储位置和程序的效率问题
- 四、CentOS下安装memcache
- 基于UML的Blog系统分析与设计之三------用例建模
- Chapter 1 Windows程序内部运行机制
- Android 多个APK共享数据(Shared User ID)
- SQL LEFT JOIN 关键字
- 读入输出优化
- ReleaseSemaphore