Home > Software engineering >  MFC LoadFrame (IDR_MAINFRAME) error Warning: constructing COleException, scode=E_FAIL
MFC LoadFrame (IDR_MAINFRAME) error Warning: constructing COleException, scode=E_FAIL

Time:10-07

Turn a VS6.0 engineering VS2012 not familiar with, got two days not fix, Posting together see
 App: : InitInstance () 
{...
CMainFrame * pMainFrame=new CMainFrame;
if (! PMainFrame | |! PMainFrame - & gt; LoadFrame (IDR_MAINFRAME))
{
The delete pMainFrame;
Return FALSE;
}
}

Load main form error and set the multibyte character set

Error:
AtlThrow: hr=0 x80004005
Warning: constructing COleException, scode=E_FAIL ($80004005).
First - chance exception at 0 x7773c52f in StkUI. Exe: Microsoft c + + exception: COleException at the memory location 0 x003ae578.
Thread 0 xfc2c have withdrawn, the return value is zero (0 x0),
Warning: Uncaught exception in WindowProc (returning - 1).

Debug tracking to: __try
{
WindowResult=CreateWindowExA (dwExStyle lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
}
After the catch to the abnormal, handle memory is initialized, CreateWindowExA function with not to,,,





CodePudding user response:

His top, and points to 99!
The great god, save me!

CodePudding user response:

Capture COleException abnormalities, and see what report error

 
Try
{
.
}
The catch (COleException * PE)
{
PE - & gt; ReportError ();
PE - & gt; The Delete ();
}

CodePudding user response:

 TRY 
{
# # ifndef _AFX_NO_OCC_SUPPORT
//special case for WM_DESTROY
If ((nMsg==WM_DESTROY) & amp; & (pWnd - & gt; M_pCtrlCont!=NULL))
PWnd - & gt; M_pCtrlCont - & gt; OnUIActivate (NULL);
# endif

//special case for WM_INITDIALOG
CRect rectOld;
DWORD dwStyle=0;
If (nMsg==WM_INITDIALOG)
_AfxPreInitDialog (pWnd, & amp; RectOld, & amp; DwStyle);

//the delegate to the object 's WindowProc
LResult=pWnd - & gt; WindowProc (nMsg wParam, lParam);

//more special case for WM_INITDIALOG
If (nMsg==WM_INITDIALOG)
_AfxPostInitDialog (pWnd, rectOld dwStyle);
}
CATCH_ALL (e)
{
LResult=AfxProcessWndProcException (e, & amp; PThreadState - & gt; M_lastSentMsg);
TRACE (traceAppMsg, 0, "Warning: Uncaught exception in WindowProc (ld) returning %. \ n",
LResult);
DELETE_EXCEPTION (e);
}
END_CATCH_ALL

Error:
AtlThrow: hr=0 x80004005
Warning: constructing COleException, scode=E_FAIL ($80004005).
First - chance exception at 0 x7773c52f in StkUI. Exe: Microsoft c + + exception: COleException at the memory location 0 x003ae578.
Thread 0 xfc2c have withdrawn, the return value is zero (0 x0),
Warning: Uncaught exception in WindowProc (returning - 1).

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
HWND HWND=CreateWindowEx (cs) dwExStyle, cs lpszClass,
Cs lpszName, cs. Style, cs. X, cs. J y, cs. Cx, cs, cy,
Cs hwndParent, cs hMenu, cs. The hInstance, cs. LpCreateParams);

# ifdef _DEBUG
If (hWnd==NULL)
{
TRACE (traceAppMsg, 0, "Warning: Window creation failed: GetLastError returns 0 X % 8.8 X \ n",
GetLastError ());
//print here: Warning: Window creation failed: GetLastError returns 0 x00000000
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Post the wrong print, deserve to go up the code, it's what you mean?

CodePudding user response:

refer to the second floor zgl7903 response:
capture COleException abnormalities, and see what report error

 
Try
{
.
}
The catch (COleException * PE)
{
PE - & gt; ReportError ();
PE - & gt; The Delete ();
}

Also, don't quite understand, single step, along with the code, mfc110d. DLL, can't edit his error capture code, can only rely on the DLL in the try, catch,
Isn't it?

CodePudding user response:

Shift + F11

CodePudding user response:

Shift + F11 jump out of the current?

CodePudding user response:

At the top once, hope not become grave post

CodePudding user response:

up! up! up! up! up! up!

CodePudding user response:

The building Lord problem solving not ah, I encountered a similar problem, good bored

CodePudding user response:

Whether have the ActiveX control? Don't forget to call AfxEnableControlContainer (); And AfxOleInit

CodePudding user response:

LoadFrame code itself is no problem, you try to press you install VS create an MFC project, the relevant copies to the relevant module code, give it a try
  • Related