Posted on 2008-07-11 13:44
寒蟬 閱讀(2866)
評論(0) 編輯 收藏 引用 所屬分類:
各種錯誤異常解決集錦
在程序中調(diào)用GetDlgItem函數(shù),編譯后運行出現(xiàn)下面的錯誤:
Debug Assertion Failed!
Program: G:\程序\源程序\RTU\MonBUS\DEBUG\MonBUS.exe File: winocc.cpp Line:76 For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
常見問題:DoModal后調(diào)用GetDlgItem導(dǎo)致以上錯誤 產(chǎn)生原因:這時候窗口已經(jīng)關(guān)閉,沒有DlgItem一說 解決方法:在退出前保存為成員變量,Member Vari; 或者創(chuàng)建非模態(tài)對話框,指針可直接調(diào)用GetDlgItem()
GetDlgItem這個函數(shù)的含義要看上下文。 解析標(biāo)識符時,首先擴展宏,然后判斷是否存在當(dāng)前類的同名成員,如果存在,那么就使用這個成員,否則按照查找父類。如果父類中多于一個類具有同名的成員,那么需要用類名::成員名區(qū)分。父類中如果也沒有找到,那么查找全局
全 局的(在上下文是CWnd的成員函數(shù)時需要用::指明)的聲明參見http://msdn.microsoft.com/library/en- us/winui/WinUI/WindowsUserInterface/Windowing/DialogBoxes/DialogBoxReference/DialogBoxFunctions/GetDlgItem.asp
CWnd的成員的聲明在http://msdn.microsoft.com/library/en-us/dv_wcemfc4/html/aflrfcwndcolcolgetdlgitem.asp
|