一個VS6.0的工程轉VS2012 不太熟悉,弄了兩天沒搞定,發帖求大家一起看看吧
App::InitInstance()
{............
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
}
Load主表單出錯,設定的多位元組字符集
錯誤輸出:
AtlThrow: hr = 0x80004005
Warning: constructing COleException, scode = E_FAIL ($80004005).
First-chance exception at 0x7773C52F in StkUI.exe: Microsoft C++ exception: COleException at memory location 0x003AE578.
執行緒 0xfc2c 已退出,回傳值為 0 (0x0)。
Warning: Uncaught exception in WindowProc (returning -1).
除錯跟蹤到: __try
{
windowResult = CreateWindowExA(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
}
這句后catch到例外。之后句柄記憶體就被初始化了。CreateWindowExA函式跟不到了。。。

uj5u.com熱心網友回復:
自己頂一下,并加分到99!大神們,救救我吧!
uj5u.com熱心網友回復:
捕捉 COleException 例外, 看看報告什么錯誤
try
{
……
}
catch(COleException *pe)
{
pe->ReportError();
pe->Delete();
}
uj5u.com熱心網友回復:
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);
// 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
錯誤輸出:
AtlThrow: hr = 0x80004005
Warning: constructing COleException, scode = E_FAIL ($80004005).
First-chance exception at 0x7773C52F in StkUI.exe: Microsoft C++ exception: COleException at memory location 0x003AE578.
執行緒 0xfc2c 已退出,回傳值為 0 (0x0)。
Warning: Uncaught exception in WindowProc (returning -1).
/************************************************************************************/
HWND hWnd = CreateWindowEx(cs.dwExStyle, cs.lpszClass,
cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);
#ifdef _DEBUG
if (hWnd == NULL)
{
TRACE(traceAppMsg, 0, "Warning: Window creation failed: GetLastError returns 0x%8.8X\n",
GetLastError());
//這里列印:Warning: Window creation failed: GetLastError returns 0x00000000
}
/*************************************************************************/
帖子里貼了錯誤列印,配上代碼,是這意思吧?
uj5u.com熱心網友回復:
還有,不太明白,單步跟的代碼都是mfc110d.dll里的,不能自己編輯錯誤捕獲代碼,只能靠dll里的try -- catch,
是不是這樣 ?
uj5u.com熱心網友回復:
shift+F11uj5u.com熱心網友回復:
shift+F11 跳出當前?uj5u.com熱心網友回復:
在頂一下,希望不會變墳貼uj5u.com熱心網友回復:
up!up!up!up!up!up!uj5u.com熱心網友回復:
樓主問題解決沒有啊,我遇到了一個同樣的問題,好煩啊
uj5u.com熱心網友回復:
是不是有ActiveX控制元件?別忘了呼叫AfxEnableControlContainer();和AfxOleInituj5u.com熱心網友回復:
LoadFrame代碼本身沒有問題,你嘗試按你安裝的VS創建一個MFC工程,將相關的代碼拷貝到相關的模塊,試試轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/118172.html
上一篇:VS2012 讀取excel資料到 double陣列
下一篇:MFC畫圖程式,拖動對話框重影
