[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Application hangs in MFC in _AfxNextControl

Posted on 2008-10-02
6
Medium Priority
?
1,463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
isprabu earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…

650 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