I don't know if it's really a dmd bug or it's a windows bug, because I made several tests and I don't really understand where is the error. Here is the code : (Working with earlier version of dmd (2.022 if I remember well) :
protected bool _onPaint(PAINTSTRUCT paintStr)
{
int oldMode = SetBkMode(paintStr.hdc, TRANSPARENT);
scope(exit)
{
SetBkMode(paintStr.hdc, oldMode);
MessageBoxA(null, "tic", "tic", MB_OK);
}
// Some code
return true;
}
If the function return without exception, the code in the scope statement is properly executed and functionnal, the Background Mode for the DC is restored to OPAQUE (it's original value).
If an exception is thrown ( with the code : (cast(Object)null).toString() for example ), The MessageBox show, but the background mode the DC is not restored, and the background simply disapear in the window.
I made some tests on the return value of SetBkMode :
If an exception is thrown, SetBkMode return OPAQUE (wich is strange, it should return TRANSPARENT according to msdn).
If no exception is thrown, SetBkMode return 0, wich is strange too, because 0 means error. I don't know what to think.
Comment #1 by clugdbug — 2009-10-30T05:37:35Z
Please attach a complete test case. It sounds like bug 1894 to me (see also bug 1087).
Comment #2 by clugdbug — 2009-12-29T22:12:51Z
I'm closing this as invalid since it has no test case. But it is probably a duplicate of one of the bugs I mentioned. Reopen if you have a complete test case.