您的位置:首页 > 移动开发

多线程中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.
     总之,我觉得最大的收获就是要记住他们的不同。恰巧在多线程中我遇到多次了!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息