Solved

Application hangs in MFC in _AfxNextControl

Posted on 2008-10-02
6
1,377 Views
Last Modified: 2013-12-03
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
Comment
Question by:netformx
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
isprabu earned 500 total points
Comment Utility
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
 

Author Comment

by:netformx
Comment Utility
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
 

Author Comment

by:netformx
Comment Utility
We use Prof-UIS third party library. Perhaps its related to Prof-UIS.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Expert Comment

by:isprabu
Comment Utility
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
 

Author Comment

by:netformx
Comment Utility
isprabu,
I don't use CPropertySheet and CPropertyPage. There is a CDialog inside CWnd in my case. CDialog contains a .Net control.
0
 

Author Comment

by:netformx
Comment Utility
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 58
Path of Workbook 3 44
Dialogbox API leak? 18 59
What .NET website keeps me current? 9 28
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now