Is it possible to catch error inside WindowProc
callback? try
/ catch
doesnt work. Looks like __try
__except
and also hardware exception (AV
, for example) doesnt work also.
Update:
I figured out that indeed this is possible to throw exception in WindowProc
callback and catch it with catch
block outside WindowProc
. Tested and works on Windows XP x86
. I found releated question 64bit exceptions in WndProc silently fail The problem seems only exist on Windows 7 x64
(and according to that question on other x64 Windows versions too).
So the question is it possible somehow to throw exception in WindowProc
and catch it with catch
block outside WindowProc
? I installed microsoft hotfix, set DisableUserModeCallbackFilter
to 1 in registry and best I get is FATAL_USER_CALLBACK_EXCEPTION
, not my exception.
The MSDN documentation for WindowProc has detailed info on exceptions thrown/propagated from WindowProc. It seems that exceptions are only propagated in 32-bit versions of Windows.
However, your original question is different from the question in your update. The first one was about catching exceptions in WindowProc, and that will work fine always. The second one is about throwing exceptions from WindowProc.
I'm not sure about the usefulness/necessity of the second one. A window procedure is normally called as a result of: