hi! i'm trying to make a double buffering to avoid the slow refresh
my code looks like this:
Code:
void draw(HDC hdc)
{
HDC dc = CreateCompatibleDC(hdc);
HBITMAP hBitmap = CreateCompatibleBitmap (hdc, 400, 240);
SelectObject(dc, hBitmap);
/*draw all the stuff on dc*/
BitBlt(hdc, 0, 0, 400, 240, dc, 0, 0, SRCCOPY);
ReleaseDC(0, dc);
DeleteObject(hBitmap);
DeleteDC(dc);
return;
}
where the hdc passed is the main hdc.
it draws but the refresh is slow. i know that is a working method because if i comment out BitBlt(hdc, 0, 0, 400, 240, dc, 0, 0, SRCCOPY); i get a black screen...
get a black screen[...]feel free to use and give suggestion!
Just a little suggestion: If you have a message loop, and if you repaint the entire client area of your window, then you don't need Windows to paint a (black in your case) background. So you could write:
Code:
case WM_ERASEBKGND:
return(1); // Prevent erasing the background to reduce flickering
break;
Bookmarks