function TForm1.DoubleBuffer(
DC: HDC; width, height: Integer; Action: TAction): HDC;
begin
if Action = CreateBuffer
then
begin
FDBufferhDCTemp := CreateCompatibleDC(
DC);
FDBufferhBMTemp := CreateCompatibleBitmap(
DC, width, height);
FDBufferhBMPrev := SelectObject(FDBufferhDCTemp, FDBufferhBMTemp);
FDBufferXx := width;
FDBufferYy := height;
FDBufferUseDC :=
DC;
Result := FDBufferhDCTemp;
end
else
begin
// Zeichne das Resultat ins Target Window
BitBlt(FDBufferUseDC, width, height, FDBufferXx, FDBufferYy, FDBufferhDCTemp, 0, 0, SRCCOPY);
// Befreie die system resourcen
SelectObject(FDBufferhDCTemp, FDBufferhBMPrev);
DeleteObject(FDBufferhBMTemp);
DeleteDC(FDBufferhDCTemp);
Result := 0;
end;
end;