Hi I have the following code to draw 3 bitmaps on the screen (of a formview):
The user can click on each bitmap and drag it around the screen but this causes extreme flickering. I've read about double buffering to reduce flicker but I'm not sure how to implement it in this example.
Please can you help?
Thanks
Code:
CBitmap bitmap[4];
CDC dcMemory[4];
BITMAP bmap[4];
int bmpWidth = 0, bmpHeight = 0;
//Load Bitmap1
bitmap[1].LoadBitmap(IDB_GUITAR1);
dcMemory[1].CreateCompatibleDC(pDC);
dcMemory[1].SelectObject(&bitmap[1]);
//Load Bitmap2
bitmap[2].LoadBitmap(IDB_GUITAR2);
dcMemory[2].CreateCompatibleDC(pDC);
dcMemory[2].SelectObject(&bitmap[2]);
//Load Bitmap3
bitmap[3].LoadBitmap(IDB_BASS);
dcMemory[3].CreateCompatibleDC(pDC);
dcMemory[3].SelectObject(&bitmap[3]);
//store bitmapnumber in new int
tempBitmapNumber = pDoc->getBitmapNumber();
strTest7.Format("tempBitmapNumber = %d", tempBitmapNumber);
pDC->TextOut(0, 140, strTest7);
for (int i = 1; i < 4; i++)
{
pDoc->setBitmapNumber(i);
//Load Bitmap
bitmap[i].GetBitmap(&bmap[i]);
bmpWidth = bmap[i].bmWidth;
bmpHeight = bmap[i].bmHeight;
//Get size of bitmap
bitmap[i].GetBitmap(&bmap[i]);
bmpWidth = bmap[i].bmWidth;
bmpHeight = bmap[i].bmHeight;
//set bitmap size
pDoc->setOriginalBitmapWidth(bmpWidth);
pDoc->setOriginalBitmapHeight(bmpHeight);
pDC->StretchBlt(pDoc->getBitmapLocationX(), pDoc->getBitmapLocationY(), pDoc->getBitmapWidth(), pDoc- >getBitmapHeight(), &dcMemory[i], 0, 0, pDoc- >getOriginalBitmapWidth(), pDoc->getOriginalBitmapHeight(), SRCCOPY);
}
The user can click on each bitmap and drag it around the screen but this causes extreme flickering. I've read about double buffering to reduce flicker but I'm not sure how to implement it in this example.
Please can you help?
Thanks