Hi there,

I am trying to get my program to double buffer, with no success. Basically, the program calls InvalidateRect whenever a timer (50 milliseconds) ticks, and here is what I have in WM_PAINT:

Code:
case WM_PAINT:
			{
		    PAINTSTRUCT Ps;
	        HBRUSH EarthBrush;
	        HBRUSH SatBrush;
			HDC hdc = BeginPaint(g_hwndWnd, &Ps);
			HDC hdcBuffer = CreateCompatibleDC(hdc);
			HBITMAP hbmBuffer = CreateCompatibleBitmap(hdc, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
            HBITMAP hbmOldBuffer = (HBITMAP)SelectObject(hdcBuffer, hbmBuffer);
			EarthBrush = CreateSolidBrush(RGB(0, 0, 250));
			SelectObject(hdcBuffer, EarthBrush);
			Ellipse(hdcBuffer, earthxcoord, earthycoord, earthxcoord+(2*6378.14*conversionfactor), earthycoord+(2*6378.14*conversionfactor));
            DeleteObject(EarthBrush);
			SatBrush = CreateSolidBrush(RGB(0, 250, 0));
            SelectObject(hdcBuffer, SatBrush);
			Ellipse(hdcBuffer, xcoord, ycoord, xcoord+10, ycoord+10);
			DeleteObject(SatBrush);
			BitBlt(hdc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), hdcBuffer, 0, 0, SRCCOPY);
			SelectObject(hdcBuffer, hbmOldBuffer);
            DeleteObject(hbmBuffer);
            DeleteDC(hdcBuffer);
	        EndPaint(g_hwndWnd, &Ps);
	    break;
			}
The variables don't make sense to you of course, but can anyone identify why this program still flickers annoyingly?

Thanks a lot! I will provide more info if necessary.