부스러기/WINAPI

더블버퍼링

artisticbit 2015. 5. 19. 16:16

      HCD  hdc = BeginPaint(hWnd, &ps);

HDC backMemDC, MemDC;

static HBITMAP backBitmap = NULL;

HBITMAP  hMyBitmap, hOldBitmap;

RECT crt;

GetClientRect(hWnd, &crt);


MemDC = CreateCompatibleDC(hdc);

hMyBitmap = CreateCompatibleBitmap(hdc, crt.right, crt.bottom);

hOldBitmap = (HBITMAP)SelectObject(MemDC, hMyBitmap);

FillRect(MemDC, &crt, (HBRUSH)GetStockObject(WHITE_BRUSH));


///// 화면 처리작업을 전부 MemDC 쪽으로 한다.

this->render(MemDC);


BitBlt(hdc, 0, 0, crt.right, crt.bottom, MemDC, 0, 0, SRCCOPY);

DeleteObject(SelectObject(MemDC, hOldBitmap));

DeleteDC(MemDC);

EndPaint(hWnd, &ps);




!!! 화면 지우는 작업을 못 해게 해준다. !!

case WM_ERASEBKGND:

return 0;