When I look at TWinControl
, the Canvas
is blanked out with clBtnFace
and then the WM_PAINT
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 WM_PAINT
event and creating more flicker.
GetMetrics
and internal scrollbar Info gives the true canvas size. Correct me if I'm wrong, but I understand an HDC
is a handle on the form that has a rectangular canvas to print on. So I'm thinking:
how do I create a new
HDC
with a smaller width and height and not move the Top Left corner. I want to remove flicker by not using aWM_ERASEBKGND
message if possible and not printing over scrollbars by allocating a newly sizedHDC
and then to set the Delphi canvas handle with the correctHDC
.using a windows bitmap that I do not know if I should use and set the Bitmap canvas size for a
BitBlt()
copy as, TWinControl (Below).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;
I do not know what option is better in a flicker free result and how to implement it in Delphi.
TWinControl
manages itsCanvas
. Please show your actual code that you are having trouble with. – Remy Lebeau