I'm experiencing some flickery graphics in this windows program. I tried using a double buffer, but I must've
done something wrong (though I'm pretty sure I did it all right).
Or is it that you cannot have completely flicker-free graphics in windows API, especially in this case where
a 640x480 screen is copied from the double buffer?
BmpPlayer and BmpTile are the HBITMAPs for the graphics.
I call this when the WM_PAINT message is sent (I invalidate the whole window if something is updated).
Code:
void RenderMap(HWND Handle)
{
   //Data
   RECT Rect;
   PAINTSTRUCT PaintStruct;
   HDC HdcWindow;
   HDC HdcBitmap;
   HDC HdcBuffer;
   HBITMAP DoubleBuffer;
   HBITMAP OldBuffer;
   HBITMAP OldDevice;

   //Setup
   Rect.left = 0;
   Rect.top = 0;
   Rect.right = SCREENWIDTH;
   Rect.bottom = SCREENHEIGHT;
   HdcWindow = BeginPaint(Handle, &PaintStruct);
   HdcBuffer = CreateCompatibleDC(HdcWindow);
   DoubleBuffer = CreateCompatibleBitmap(HdcWindow, SCREENWIDTH, SCREENHEIGHT);
   OldBuffer = (HBITMAP)SelectObject(HdcBuffer, DoubleBuffer);

   //Clear background
   FillRect(HdcBuffer, &Rect, (HBRUSH)GetStockObject(WHITE_BRUSH));

   //Draw the tiles
   HdcBitmap = CreateCompatibleDC(HdcWindow);
   OldDevice =(HBITMAP)SelectObject(HdcBitmap, BmpTile);
   BitBlt(HdcBuffer, 32, 64, 32, 32, HdcBitmap, 0, 0, SRCCOPY);
   BitBlt(HdcBuffer, 128, 96, 32, 32, HdcBitmap, 32, 0, SRCCOPY);

   //Draw the items

   //Draw the enemies

   //Draw the effects

   //Draw the player
   SelectObject(HdcBitmap, BmpPlayer);
   BitBlt(HdcBuffer, Header.StartPosition.X, Header.StartPosition.Y, 32, 64, 
          HdcBitmap, 0, 0, SRCCOPY);

   //Copy data from buffer to window
   BitBlt(HdcWindow, 0, 0, SCREENWIDTH, SCREENHEIGHT, HdcBuffer, 0, 0, SRCCOPY);

   //Shutdown
   SelectObject(HdcBuffer, OldBuffer);
   DeleteDC(HdcBuffer);
   SelectObject(HdcBitmap, OldDevice);
   DeleteDC(HdcBitmap);
   DeleteObject(DoubleBuffer);
   EndPaint(Handle, &PaintStruct);
}
PS: This will only be the level editor for the game. The real game will be made in DX .