sharda_arvind
April 26th, 2005, 07:53 AM
Hi
I am facing a strange problem ,
CMainFrame* pMainFrm = (CMainFrame*) (AfxGetMainWnd());
pMainFrm->...//giving NULL
but it is working fine in case of VC6
Thanks for ur help
cilu
April 26th, 2005, 09:40 AM
Did you compile in VC++7.0 a project from VC++6.0 and this part is not working? Or is this something different, but you know from VC++ 6.0 that AfxGetMainWnd() should work?
Where is this code taken from? Class, method, thread... Is it from the main thread or a secondary thread? Is it a worker thread?
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.
If the thread does not have a window associated, then it returns NULL.