// JP opened flex table

Click to See Complete Forum and Search --> : GDI BITMAP issue


Kiryn
September 7th, 2007, 12:44 AM
I create a double buffer with a bitmap. And no more flickering yay!!!
But I get a black background and now I can't figure out how to change it back to grey

case WM_PAINT:
{
RECT bufferRect;
::GetClientRect(hWnd, &bufferRect);
int buffer_x = bufferRect.right - bufferRect.left;
int buffer_y = bufferRect.bottom - bufferRect.top;
hdc = ::BeginPaint(hWnd, &ps);
hdcBuffer = ::CreateCompatibleDC(hdc);
buffer = ::CreateCompatibleBitmap(hdc, buffer_x, buffer_y);
::SelectObject(hdcBuffer, buffer);
::Rectangle(hdcBuffer, 50, 50, 200, 100);
::BitBlt(hdc, 0, 0, buffer_x, buffer_y, hdcBuffer, 0, 0, SRCCOPY);
::DeleteDC(hdcBuffer);
::DeleteObject(buffer);
::ReleaseDC(hWnd, hdc);
::EndPaint(hWnd, &ps);
}
break;

JVene
September 7th, 2007, 09:08 AM
The bitmap will be initialized to all black, so naturally the background of the blitted image would be black.

Simply initialize the painting cycle with an 'erase' of the background, by drawing a gray (or whatever background color you want) rectangle with a null border pen before you begin painting.

//JP added flex table