Posted on 2008-07-11 13:44
寒蟬 閱讀(2856)
評論(0) 編輯 收藏 引用 所屬分類:
各種錯誤異常解決集錦
在程序中調用GetDlgItem函數,編譯后運行出現下面的錯誤:
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后調用GetDlgItem導致以上錯誤 產生原因:這時候窗口已經關閉,沒有DlgItem一說 解決方法:在退出前保存為成員變量,Member Vari; 或者創建非模態對話框,指針可直接調用GetDlgItem()
GetDlgItem這個函數的含義要看上下文。 解析標識符時,首先擴展宏,然后判斷是否存在當前類的同名成員,如果存在,那么就使用這個成員,否則按照查找父類。如果父類中多于一個類具有同名的成員,那么需要用類名::成員名區分。父類中如果也沒有找到,那么查找全局
全 局的(在上下文是CWnd的成員函數時需要用::指明)的聲明參見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
|