Exceptions and Access Violations in Paint events in Windows

余生颓废 提交于 2019-12-04 09:12:24

It's a known defect. Check the hotfix. http://support.microsoft.com/kb/976038

My immediate reaction is that this sounds like a resource leak, with the failure occurring when you no longer have a resource of the correct kind available.

[ I've deleted the rest of the previous answer, because based upon Patrick's comments and a bit of investigation, it was clearly inapplicable to the problem at hand. ]

Following up to Patrick's comment, I did a quick test and duplicated the behavior under Windows 7. I started with a truly minimal program (the basic program generated by VS 2008 for a Win32 project) and all I added was a write to a nonexistent address. Sure enough, you get no sign of anything bad having happened at all.

Just for grins I did a quick test to see exactly how it's reacting to the exception. For what it's worth, it's not resuming after the exception, it's just trapping it and skipping the remainder of the code in the WM_PAINT handler.

I've done a bit of looking in MSDN, but so far haven't found any documentation that explains how or why this came about, whether it can be disabled, and if so how, or much of anything else. I have to agree though: this really as a serious problem -- if I've caused an access violation (no, couldn't happen!) I want the program to crash as thoroughly and quickly as possible. Masking a bug (especially one as serious as an access violation) is a spectacularly bad idea!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!