Browse - programming tips - afxgetmainwnd returns nullDate: 2010jan24 Product: Visual Studio Q. AfxGetMainWnd() is returning NULL. What can I do about this? A. Apparently it turns NULL when called from a thread other than the main one. Which mains its not very useful. Before Visual Studio 2005 it worked fine. Use this function instead: inline CWnd *MyGetMainWnd() { CWinApp *app; if ((app = AfxGetApp()) == NULL) return NULL; return app->m_pMainWnd; }
Add a commentSign in to add a comment |