多线程中AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别?
2005-09-20 16:38
721 查看
一个最普通的对话框程序,是用afxbeginthread新建一个线程,在里面是用
CxxDlg * dlgPtr=(CxxDlg *)AfxGetApp()->m_pMainWnd;
跟
CxxDlg * dlgPtr=(CxxDlg *)AfxGetMainWnd() ;
两个代码得到的dlgPtr是不是一样的 你们觉得??
在我在线程函数中使用dlgPtr->xxx传对话框的一个成员变量到线程函数中,两个dlgptr的指针肯定是不一样的,有位前辈给我的说明是:
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.
总之,我觉得最大的收获就是要记住他们的不同。恰巧在多线程中我遇到多次了!!
CxxDlg * dlgPtr=(CxxDlg *)AfxGetApp()->m_pMainWnd;
跟
CxxDlg * dlgPtr=(CxxDlg *)AfxGetMainWnd() ;
两个代码得到的dlgPtr是不是一样的 你们觉得??
在我在线程函数中使用dlgPtr->xxx传对话框的一个成员变量到线程函数中,两个dlgptr的指针肯定是不一样的,有位前辈给我的说明是:
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.
总之,我觉得最大的收获就是要记住他们的不同。恰巧在多线程中我遇到多次了!!
相关文章推荐
- AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别
- AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别
- AfxGetApp()->m_pMainWnd和AfxGetMainWnd() 的区别
- AfxGetApp()->GetMainWnd与AfxGetMainWnd的区别
- AfxGetMainWnd与AfxGetApp->m_pMainWnd
- AfxGetApp()->GetMainWnd()和AfxGetMainWnd()的区别
- AfxGetApp()->m_pMainWnd和AfxGetMainWnd()
- AfxGetApp()->GetMainWnd()和AfxGetMainWnd()的区别
- afxgetapp->afxmainwnd 与afxgetmainwnd的区别 /线程中调用afxgetmainwnd的问题
- AfxGetApp()->GetMainWnd()->GetSafeHwnd()
- AfxGetApp->GetMainWnd()与AfxGetMainWnd
- AfxGetApp->GetMainWnd()与AfxGetMainWnd
- AfxGetApp->GetMainWnd()与AfxGetMainWnd
- AfxGetApp->GetMainWnd()与AfxGetMainWnd的不同
- AfxGetApp->GetMainWnd()与AfxGetMainWnd
- 慎用AfxGetApp()->GetMainWnd()->m_hWnd
- AfxGetApp->GetMainWnd()与AfxGetMainWnd
- 前台线程与后台线程,AfxGetApp->GetMainWnd()与AfxGetMainWnd的不同 (转)
- 前台线程与后台线程,AfxGetApp->GetMainWnd()与AfxGetMainWnd的不同
- AfxGetApp->GetMainWnd()与AfxGetMainWnd