Re: Problem with refreshing animated bitmap
Hmm, I think that is what I'm doing:
void My_CMainWnd::OnPaint ()
{
CRect rcClient1;
GetClientRect(&rcClient1);
CPaintDC dce(this);
CDC dcMem;
int CheckErr = dcMem.CreateCompatibleDC(&dce);
if (CheckErr == 0)
MessageBox(_T("Couldn't create memory DC"),0,0);
CBitmap * pOldBitmap = (CBitmap*)dcMem.SelectObject(myEng-
TloBitmap); <--- here myEng->TloBitmap is my background bitmap
dcMem.FloodFill(0,0,RGB(255,255,255)); <---
ive added this flood fill
myEng->BBitmap->DrawTransparent(&dcMem,myEng->Balls->BCoordinates-
x,myEng->Balls->BCoordinates->y,RGB(255,0,255)); <-- moving bitmap is
blitted to dcMem
dce.BitBlt(0,0,rcClient1.Width(),rcClient1.Height(),&dcMem,
0,0,SRCCOPY);
dcMem.SelectObject(pOldBitmap);
dcMem.DeleteDC();
}
Earlier without that floodfill there was my background bitmap
displayed properly except those dots as in the screenshot. As I
understand by doing SelectObject() I choose the bitmap that will be
displayed in the background of the DC and then if I want to add
anything to it I use BitBlt, also the pOldBitmap is the pointer to the
previous object so anything that was changed in dcMem will be brought
to earlier state. I wonder if maybe I'm handling this CPaintCD dce in
a wrong way, and something stays in it, but then it probably would
cause strange things while moving/minimizing/maximizing the window,
and here everything stays as it is when I hide the window and then
focus on it again, and I'm declaring new CPaintCD every WM_PAINT...
the effect is such:
http://frd.no-ip.pl/screenshot.jpg
I also thought that maybe my workerthread is broken, but when I'm
using a Timer the same thing happens. In this workerthread I've got
just one MASM assembly function,
and Invalidate()...