• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1477
  • Last Modified:

Application hangs in MFC in _AfxNextControl

In MDI application I use CWinFormsControl to host a Windows Forms control. The application is a standard MFC application and the control is implemented in C#. When I open a window containing a Windows Forms control and click on another window (MFC based window) the application hangs. The following is a call stack:

>      mfc80d.dll!_AfxRemoveDefaultButton(CWnd * pWndRoot=0x2117d09c, CWnd * pWndStart=0x0d3c19b0)  Line 483      C++
       mfc80d.dll!_AfxCheckDefPushButton(CWnd * pWndRoot=0x2117d09c, CWnd * pWndOldFocus=0x1926dddc, CWnd * pWndNewFocus=0x0d42f6b0)  Line 549      C++
       mfc80d.dll!COccManager::IsDialogMessageA(CWnd * pWndDlg=0x2117d09c, tagMSG * lpMsg=0x0015d790)  Line 816      C++
       mfc80d.dll!CWnd::IsDialogMessageA(tagMSG * lpMsg=0x0015d790)  Line 195 + 0x20 bytes      C++
       mfc80d.dll!CWnd::PreTranslateInput(tagMSG * lpMsg=0x0015d790)  Line 4268      C++
       mfc80d.dll!CControlBar::PreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 443 + 0xc bytes      C++
       mfc80d.dll!CWnd::WalkPreTranslateTree(HWND__ * hWndStop=0x00080aee, tagMSG * pMsg=0x0015d790)  Line 2882 + 0x14 bytes      C++
       mfc80d.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 233 + 0x12 bytes      C++
       mfc80d.dll!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 773 + 0x9 bytes      C++
       mfc80d.dll!AfxPreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 252 + 0x11 bytes      C++
       mfc80d.dll!AfxInternalPumpMessage()  Line 178 + 0x18 bytes      C++
       mfc80d.dll!CWinThread::PumpMessage()  Line 896      C++
       mfc80d.dll!CWinThread::Run()  Line 625 + 0xd bytes      C++
       mfc80d.dll!CWinApp::Run()  Line 894      C++
       mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00151f05, int nCmdShow=5)  Line 47 + 0xd bytes      C++
       Netedit.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00151f05, int nCmdShow=5)  Line 33      C++
       Netedit.exe!__tmainCRTStartup()  Line 589 + 0x35 bytes      C
       Netedit.exe!WinMainCRTStartup()  Line 414      C

The application hangs inside MFC in _AfxRemoveDefaultButton method. The code below I copied from _AfxRemoveDefaultButton:

      do
      {
            COccManager::SetDefaultButton(pWnd, FALSE);
            pWndNext = _AfxNextControl(pWndRoot, pWnd, 0);
            pWnd = pWndNext;
      }
      while ((pWnd != NULL) && (pWnd != pWndStart));


_AfxNextControl always returns the same window and AfxRemoveDefaultButton is stuck in the loop.
0
netformx
Asked:
netformx
  • 4
  • 2
1 Solution
 
isprabuCommented:
netformx,
Your issue could be related to this one:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q149501
(PRB: Child CPropertySheet Hangs If Focus Is Switched)

Please have a look at this and let me know.

Hope this helps!
0
 
netformxAuthor Commented:
isprabu,

Thank you for the attempt to help. I modified the code according to the article, but this did not resolve the problem. My application still hangs. This is the new call stack:

>      mfc80d.dll!CInternalGlobalLock::CInternalGlobalLock(int nLockType=2147483647)  Line 461 + 0x1 bytes      C++
       mfc80d.dll!CWnd::OnWndMsg(unsigned int message=135, unsigned int wParam=0, long lParam=0, long * pResult=0x0012fa04)  Line 1751 + 0xd bytes      C++
       mfc80d.dll!CWnd::WindowProc(unsigned int message=135, unsigned int wParam=0, long lParam=0)  Line 1741 + 0x20 bytes      C++
       mfc80d.dll!AfxCallWndProc(CWnd * pWnd=0x1c704598, HWND__ * hWnd=0x00091c00, unsigned int nMsg=135, unsigned int wParam=0, long lParam=0)  Line 240 + 0x1c bytes      C++
       mfc80d.dll!AfxWndProc(HWND__ * hWnd=0x00091c00, unsigned int nMsg=135, unsigned int wParam=0, long lParam=0)  Line 389      C++
       mfc80d.dll!AfxWndProcBase(HWND__ * hWnd=0x00091c00, unsigned int nMsg=135, unsigned int wParam=0, long lParam=0)  Line 411 + 0x15 bytes      C++
       user32.dll!7e418734()       
       [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]      
       user32.dll!7e418816()       
       user32.dll!7e428ea0()       
       user32.dll!7e45879a()       
       ntdll.dll!7c90e453()       
       user32.dll!7e4194be()       
       user32.dll!7e42c174()       
       user32.dll!7e4292e3()       
       user32.dll!7e424c99()       
       user32.dll!7e42603e()       
       user32.dll!7e44715f()       
       user32.dll!7e43c6d3()       
       mfc80d.dll!COccManager::IsDialogMessageA(CWnd * pWndDlg=0x1c7a2a2c, tagMSG * lpMsg=0x0015d790)  Line 805 + 0x11 bytes      C++
       mfc80d.dll!CWnd::IsDialogMessageA(tagMSG * lpMsg=0x0015d790)  Line 195 + 0x20 bytes      C++
       mfc80d.dll!CWnd::PreTranslateInput(tagMSG * lpMsg=0x0015d790)  Line 4268      C++
       mfc80d.dll!CControlBar::PreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 443 + 0xc bytes      C++
       mfc80d.dll!CWnd::WalkPreTranslateTree(HWND__ * hWndStop=0x000f16aa, tagMSG * pMsg=0x0015d790)  Line 2882 + 0x14 bytes      C++
       mfc80d.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 233 + 0x12 bytes      C++
       mfc80d.dll!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 773 + 0x9 bytes      C++
       mfc80d.dll!AfxPreTranslateMessage(tagMSG * pMsg=0x0015d790)  Line 252 + 0x11 bytes      C++
       mfc80d.dll!AfxInternalPumpMessage()  Line 178 + 0x18 bytes      C++
       mfc80d.dll!CWinThread::PumpMessage()  Line 896      C++
       mfc80d.dll!CWinThread::Run()  Line 625 + 0xd bytes      C++
       mfc80d.dll!CWinApp::Run()  Line 894      C++
       mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00151f06, int
0
 
netformxAuthor Commented:
We use Prof-UIS third party library. Perhaps its related to Prof-UIS.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
isprabuCommented:
netformx,
This issue may not be related the 3rd party library. There seems to a recurring problem reported in case of cproperty Sheet - seems to happen while setting the active property sheet tab using the normal way.
I have read some where, the work around for this is to use postmessage to select the active tab in propertysheet.
In case if you are trying to change the current active tab in your code, try to change it:
 PostMessage (PSM_SETCURSEL, page_number);

Please let me know if this helps!
0
 
netformxAuthor Commented:
isprabu,
I don't use CPropertySheet and CPropertyPage. There is a CDialog inside CWnd in my case. CDialog contains a .Net control.
0
 
netformxAuthor Commented:
thanks
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now