title: Help with double-buffering
body: <p>I have created an animation which works fine, but it flicks.  I need help with double-buffering since I don't know anything about it. </p>
  
  <p>This is the code in my onPaint():</p>
  
  <pre><code>VOID onPaint(HDC hdc)
  {
      Graphics graphics(hdc);
      Pen      pen(Color(255, 0, 0, 255));
      graphics.DrawEllipse(&amp;pen, sf , 0, 10, 10);
  }
  </code></pre>
  
  <p>It works fine but with flicker.  I tried this code but it didn't work:</p>
  
  <pre><code>VOID onPaint(HDC hdc,HWND hWnd)
  {
      HDC hDC=GetDC(hWnd);;
      HDC memDC = CreateCompatibleDC(hDC);
      HBITMAP hMemBmp = CreateCompatibleBitmap(hDC,10,10);
      HBITMAP hOldBmp =  (HBITMAP)SelectObject(memDC,hMemBmp);
      BitBlt(hDC, 0, 0, 10, 10, memDC, 0, 0, SRCCOPY);
      Graphics graphics(memDC);
      Pen      pen(Color(255, 0, 0, 255));
      graphics.DrawEllipse(&amp;pen, sf , 0, 10, 10);
  
      // Always select the old bitmap back into the device context
      SelectObject(memDC, hOldBmp);
      DeleteObject(hMemBmp);
      DeleteDC(memDC);
  }
  </code></pre>