title: Delphi creating a paint event canvas issues
body: <p>When I look at <code>TWinControl</code>, the <code>Canvas</code> is blanked out with <code>clBtnFace</code> and then the <code>WM_PAINT</code> is called. This causes an unavoidable flicker that I do not need. Also the canvas given allows drawing over the scroll bars making the scroll bars to be redrawn after a <code>WM_PAINT</code> event and creating more flicker.</p>
  
  <p><code>GetMetrics</code> and internal scrollbar Info gives the true canvas size. Correct me if I'm wrong, but I understand an <code>HDC</code> is a handle on the form that has a rectangular canvas to print on. So I'm thinking:</p>
  
  <ol>
  <li><p>how do I create a new <code>HDC</code> with a smaller width and height and not move the Top Left corner. I want to remove flicker by not using a <code>WM_ERASEBKGND</code> message if possible and not printing over scrollbars by allocating a newly sized <code>HDC</code> and then to set the Delphi canvas handle with the correct <code>HDC</code>.</p></li>
  <li><p>using a windows bitmap that I do not know if I should use and set the Bitmap canvas size for a <code>BitBlt()</code> copy as, TWinControl (Below).</p>
  
  <pre><code>DC := GetDC(0);
  MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right, ClientRect.Bottom);
  ReleaseDC(0, DC);
  MemDC := CreateCompatibleDC(0);
  OldBitmap := SelectObject(MemDC, MemBitmap);
  try
    DC := BeginPaint(Handle, PS);
    Perform(WM_ERASEBKGND, MemDC, MemDC);
    Message.DC := MemDC;
    WMPaint(Message);
    Message.DC := 0;
    BitBlt(DC, 0, 0, ClientRect.Right, ClientRect.Bottom, MemDC, 0, 0, SRCCOPY);
    EndPaint(Handle, PS);
  finally
    SelectObject(MemDC, OldBitmap);
    DeleteDC(MemDC);
    DeleteObject(MemBitmap);
  end;
  </code></pre></li>
  </ol>
  
  <p>I do not know what option is better in a flicker free result and how to implement it in Delphi. </p>