Solved

Application hangs in MFC in _AfxNextControl

Posted on 2008-10-02
6
1,400 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
ID: 22687166
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
ID: 22718981
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
ID: 22718993
We use Prof-UIS third party library. Perhaps its related to Prof-UIS.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 5

Expert Comment

by:isprabu
ID: 22723222
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
ID: 22820024
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
ID: 25584610
thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
twoTwo  challenge 35 101
Fibonacci challenge 11 121
Problem to event 3 94
Where did System.Data.Objects go? 2 23
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…

785 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