I have searched for ages trying to find a way to remove the flicker from a bitmap, rendered into a window with the below code (it is rendered on a WM_PAINT message within an owner-drawn tab control. It works but flickers really badly when resizing the window. I have tried returning false on WM_ERASEBKGND in both the main wndproc and the tab controls proc too, but its still rubbish. I read about the CMemDC, but my app is API, not MFC. Can anyone help?
VOID CImage::Draw(HWND hWnd, LPRECT rect)
hDC = GetDC(hWnd);
hCompatibleDC = CreateCompatibleDC(hDC);
hOldBitmap = (HBITMAP) SelectObject(hCompatibleDC, hImageBitmap);
GetObject(hImageBitmap, sizeof(imageBitmap), &imageBitmap);
StretchBlt(hDC, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, hCompatibleDC, 0, 0, imageBitmap.bmWidth, imageBitmap.bmHeight, SRCCOPY);