我正在开发一个SDI MFC应用程序,其中有一些自定义按钮以自定义方式绘制或者图像加载在它们之上.当正在运行的应用程序连续重新调整大小约5到10分钟时,它会因错误"未找到所需资源"而崩溃.
我已经彻底检查了代码,所有的GetDC()
呼叫都跟着ReleaseDC()
电话.此外,每当我DC.SelectObject(&newBrush)
打电话然后恢复旧笔时,我总是保存旧的GDI对象(例如,oldBrush)DC.SelectObject(&oldBrush)
.
什么其他可能导致此错误的任何提示?
编辑:我使用程序Deleaker来查找程序中的GDI泄漏并删除导致泄漏的那些GDI对象.
编辑:这是AfxThrowResourceException的调用堆栈:
mfc110ud.dll!AfxThrowResourceException() Line 1353 C++ mfc110ud.dll!CWindowDC::CWindowDC(CWnd * pWnd) Line 1022 C++ mfc110ud.dll!CMFCToolBarImages::PrepareDrawImage(tagAFXDrawState & ds, CSize sizeImageDest, int bFadeInactive) Line 1219 C++ mfc110ud.dll!CMFCToolBarImages::DrawEx(CDC * pDC, CRect rect, int iImageIndex, CMFCToolBarImages::ImageAlignHorz horzAlign, CMFCToolBarImages::ImageAlignVert vertAlign, CRect rectSrc, unsigned char alphaSrc) Line 1729 C++ mfc110ud.dll!CMFCControlRenderer::FillInterior(CDC * pDC, CRect rect, CMFCToolBarImages::ImageAlignHorz horz, CMFCToolBarImages::ImageAlignVert vert, unsigned int index, unsigned char alphaSrc) Line 470 C++ mfc110ud.dll!CMFCControlRenderer::FillInterior(CDC * pDC, CRect rect, unsigned int index, unsigned char alphaSrc) Line 474 C++ mfc110ud.dll!CMFCControlRenderer::Draw(CDC * pDC, CRect rect, unsigned int index, unsigned char alphaSrc) Line 253 C++ mfc110ud.dll!CMFCVisualManagerOffice2007::DrawNcCaption(CDC * pDC, CRect rectCaption, unsigned long dwStyle, unsigned long dwStyleEx, const ATL::CStringT> > & strTitle, const ATL::CStringT > > & strDocument, HICON__ * hIcon, int bPrefix, int bActive, int bTextCenter, const CObList & lstSysButtons) Line 2097 C++ mfc110ud.dll!CMFCVisualManagerOffice2007::OnNcPaint(CWnd * pWnd, const CObList & lstSysButtons, CRect rectRedraw) Line 2343 C++ mfc110ud.dll!CFrameImpl::OnNcPaint() Line 1564 C++ mfc110ud.dll!CFrameWndEx::OnNcPaint() Line 1030 C++ mfc110ud.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2459 C++ mfc110ud.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2137 C++ mfc110ud.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 290 C++ mfc110ud.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 453 C++ mfc110ud.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 304 C++
xMRi.. 5
我确定您有GDI或其他Windows资源泄漏.消息文本来自MFC中的内部异常.
你看到的是调用AfxThrowResourceException的结果.在调试器中设置此函数的断点,您可以看到操作失败.
由于这个行为你知道你是否有内存或GDI泄漏,或者可能是其他手柄泄漏......
我确定您有GDI或其他Windows资源泄漏.消息文本来自MFC中的内部异常.
你看到的是调用AfxThrowResourceException的结果.在调试器中设置此函数的断点,您可以看到操作失败.
由于这个行为你知道你是否有内存或GDI泄漏,或者可能是其他手柄泄漏......