CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2000
    Location
    Austria/Vienna
    Posts
    86

    Unhappy Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Hi,

    i have a dialog based MFC app.
    During my coding i get now following error during the Init Process of the first dialog!

    So this means before i can see a dialog my app crashes:

    Unhandled exception at 0x7c22c81a (mfc71d.dll) in menutree.exe: 0xC0000005: Access violation reading location 0x04a9092d.

    Here the Call Stack:

    mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x0012fdac, HWND__ * hWnd=0x00130810, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0) Line 241 + 0x14 C++
    mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x00130810, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0) Line 389 C++
    > mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x00130810, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0) Line 209 + 0x15 C++
    user32.dll!77d486cb()
    user32.dll!77d4879f()
    user32.dll!77d492ab()
    user32.dll!77d492f5()
    ntdll.dll!77f75da3()
    user32.dll!77d4ab37()
    user32.dll!77d4ab23()
    user32.dll!77d565cb()
    user32.dll!77d5657b()
    user32.dll!77d5659f()
    mfc71d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x004a6ed0, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Line 310 + 0x2a C++
    mfc71d.dll!CDialog:oModal() Line 519 + 0x20 C++
    menutree.exe!CMenutreeApp::InitInstance() Line 63 + 0xb C++
    mfc71d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f4a, int nCmdShow=1) Line 39 + 0xb C++
    menutree.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f4a, int nCmdShow=1) Line 25 C++
    menutree.exe!WinMainCRTStartup() Line 390 + 0x39 C
    kernel32.dll!77e8141a()


    The error occure on following part:
    wincore.cpp
    Code:
    /////////////////////////////////////////////////////////////////////////////
    // Official way to send message to a CWnd
    
    LRESULT AFXAPI AfxCallWndProc(CWnd* pWnd, HWND hWnd, UINT nMsg,
    	WPARAM wParam = 0, LPARAM lParam = 0)
    {
    	_AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData();
    	MSG oldState = pThreadState->m_lastSentMsg;   // save for nesting
    	pThreadState->m_lastSentMsg.hwnd = hWnd;
    	pThreadState->m_lastSentMsg.message = nMsg;
    	pThreadState->m_lastSentMsg.wParam = wParam;
    	pThreadState->m_lastSentMsg.lParam = lParam;
    
    #ifdef _DEBUG
    	_AfxTraceMsg(_T("WndProc"), &pThreadState->m_lastSentMsg);
    #endif
    
    	// Catch exceptions thrown outside the scope of a callback
    	// in debug builds and warn the user.
    	LRESULT lResult;
    	TRY
    	{
    #ifndef _AFX_NO_OCC_SUPPORT
    		// special case for WM_DESTROY
    		if ((nMsg == WM_DESTROY) && (pWnd->m_pCtrlCont != NULL))
    			pWnd->m_pCtrlCont->OnUIActivate(NULL);				
    #endif
    
    		// special case for WM_INITDIALOG
    		CRect rectOld;
    		DWORD dwStyle = 0;
    		if (nMsg == WM_INITDIALOG)
    			_AfxPreInitDialog(pWnd, &rectOld, &dwStyle);
    
    		// delegate to object's WindowProc
    		lResult = pWnd->WindowProc(nMsg, wParam, lParam);   :confused: 
    
    		// more special case for WM_INITDIALOG
    		if (nMsg == WM_INITDIALOG)
    			_AfxPostInitDialog(pWnd, rectOld, dwStyle);
    	}
    	CATCH_ALL(e)
    	{
    		lResult = AfxProcessWndProcException(e, &pThreadState->m_lastSentMsg);
    		TRACE(traceAppMsg, 0, "Warning: Uncaught exception in WindowProc (returning %ld).\n",
    			lResult);
    		DELETE_EXCEPTION(e);
    	}
    	END_CATCH_ALL
    
    	pThreadState->m_lastSentMsg = oldState;
    	return lResult;
    }
    what can be the problem??

    Do you need more infos to help me!

    Thanks!

    Gernot

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Look in your function " menutree.exe!CMenutreeApp::InitInstance() Line 63 + 0xb C++" This is where the problem is.

    What does your InitInstance look like?

    Viggy

  3. #3
    Join Date
    Aug 2000
    Location
    Austria/Vienna
    Posts
    86

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Hi,

    here is my initInstance:

    Line 63 is marked bold!!

    Code:
    BOOL CMenutreeApp::InitInstance()
    {
    	// InitCommonControls() is required on Windows XP if an application
    	// manifest specifies use of ComCtl32.dll version 6 or later to enable
    	// visual styles.  Otherwise, any window creation will fail.
    	InitCommonControls();
    
    	CWinApp::InitInstance();
    
    	AfxEnableControlContainer();
    
    	// Standard initialization
    	// If you are not using these features and wish to reduce the size
    	// of your final executable, you should remove from the following
    	// the specific initialization routines you do not need
    	// Change the registry key under which our settings are stored
    	// TODO: You should modify this string to be something appropriate
    	// such as the name of your company or organization
    	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
    
    	CMenutreeDlg dlg;
    	m_pMainWnd = &dlg;
    	INT_PTR nResponse = dlg.DoModal();
    	if (nResponse == IDOK)
    	{
    		// TODO: Place code here to handle when the dialog is
    		//  dismissed with OK
    	}
    	else if (nResponse == IDCANCEL)
    	{
    		// TODO: Place code here to handle when the dialog is
    		//  dismissed with Cancel
    	}
    
    	// Since the dialog has been closed, return FALSE so that we exit the
    	//  application, rather than start the application's message pump.
    	return FALSE;
    }
    But whats the problem!
    This is generated automatically from the .Net environment!?!?!?!?

    Thanks

  4. #4
    Join Date
    Aug 2000
    Location
    Austria/Vienna
    Posts
    86

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    HI!

    I found the error!!!!

    I load during the OnInitDialog the different Icons, which i use.

    hIcon[0] = AfxGetApp()->LoadIcon(IDI_COMP);
    hIcon[1] = AfxGetApp()->LoadIcon(IDI_COMP1);
    ....

    and this runs until 24 items.

    And i set the HICON hIcon in the header file only to 23. So it crashes, because i try to access a not existing hicon element.

    Thanks for you investigation

    bye
    Gernot

  5. #5
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    That'll do it!!!!

    Viggy

  6. #6
    Join Date
    Mar 2016
    Posts
    1

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Hello.. i have same problem like this. Please help me.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Quote Originally Posted by maas View Post
    Hello.. i have same problem like this. Please help me.
    Well, then fix it the same way like this.
    Victor Nijegorodov

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    [thread was moved from Managed C++/CLI forum...]
    Victor Nijegorodov

  9. #9
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Quote Originally Posted by VictorN View Post
    [thread was moved from Managed C++/CLI forum...]
    Eventually... It's been in C++/CLI since 11 years... ☺
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Unhandled exception at 0x7c22c81a (mfc71d.dll) during InitDialog

    Quote Originally Posted by Eri523 View Post
    Eventually... It's been in C++/CLI since 11 years... ☺
    Yes. Unfortunately... Although there is nothing concerning managed code. Only the native one.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured