Bitmaps don't paint in memory DC
I am having difficulty displaying bitmaps
When I start my app, everything works as expected; the screen is
painted with the corrected bitmaps
But after the app has run for 20 min or so, I get an error when I
create a compatible device context. As far as I can tell, there is no
error information available; the DC just comes back NULL.
Here is an outline of the OnPaint code that fails. This code is
supposed to paint part of the screen using some precalculated bitmaps
and masks.
void CBoard::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC dcMem; dcMem.CreateCompatibleDC(&dc); // make a "memory DC"
if(dcMem==NULL)
{
return; // UNEXPECTED ERROR
}
CBitmap *oldBM=dcMem.SelectObject(&bitmap[0]);
... several iterations of ...
dcMem.SelectObject(&mask[i]);
ok=dc.BitBlt(x,y,w,h,&dcMem,0,0,SRCAND);
dcMem.SelectObject(&bitmap[i]);
ok=dc.BitBlt(x,y,w,h,&dcMem,0,0,SRCPAINT);
dcMem.SelectObject(&oldBM);
dcMem.DeleteDC();
}
Can anyone see what I am doing wrong? This fails under WinXP and
WinXP64.