Changing CFrameWnd to CFrameWndEx in MFC raises an unhandled exception - any ideas?

Still used to this MFC lark, and I hit a brick wall on this particular issue. I am updating some old code to use some of the more advanced controls available in the MFC function pack.

Following the examples on the Internet for updating an old MFC application, changing the base class of the application to CWinAppEx works fine, but when I change CFrameWnd to CFrameWndEx, I get a "Debugging Error" error that comes from somewhere in mfc90d.dll! AFXGetRegPath. Ignoring this message leads to error 0xC0000005: access violation error.

I would be grateful for any suggestions on how to fix this.

Greetings.

+3
source share
1 answer

The source code for the MFC environment is included as part of Visual Studio, so you must install it on your computer. In general, when the framework launches a debug statement, you should go into the debugger and this will help you determine the exact cause of the problem.

After looking at the source code, I see that the function AFXGetRegPathcontains several statements:

ENSURE(lpszPostFix != NULL);
ASSERT_VALID(pApp);
ENSURE(AfxGetApp()->m_pszRegistryKey != NULL);
ENSURE(AfxGetApp()->m_pszProfileName != NULL);

If I had to guess, I would say that it m_pszRegistryKeychecks that this fails, perhaps because you are not calling the SetRegistryKeyapplication in your class InitInstance.

Hope this helps!

+4
source

Source: https://habr.com/ru/post/1764705/


All Articles