From 0b23f54b345c7a6bae80345ff6908e8fd2ceb497 Mon Sep 17 00:00:00 2001 From: micha Date: Wed, 7 Jan 2004 18:05:46 +0000 Subject: [PATCH] add TWinControl.DoubleBuffered property which is a hint for the interface to do double-buffering for this control git-svn-id: trunk@5026 - --- lcl/controls.pp | 5 +++ lcl/interfaces/win32/win32callback.inc | 49 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/lcl/controls.pp b/lcl/controls.pp index bd99d3aad4..cc9e2e6d1c 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -975,6 +975,7 @@ type FControls: TList; FDefWndProc: Pointer; //FDockSite: Boolean; + FDoubleBuffered: Boolean; FClientWidth: Integer; FClientHeight: Integer; FDockManager: TDockManager; @@ -1120,6 +1121,7 @@ type property DockClients[Index: Integer]: TControl read GetDockClients; property DockSite: Boolean read FDockSite write SetDockSite default False; property DockManager: TDockManager read FDockManager write FDockManager; + property DoubleBuffered: Boolean read FDoubleBuffered write FDoubleBuffered; property IsResizing: Boolean read GetIsResizing; property OnDockDrop: TDockDropEvent read FOnDockDrop write FOnDockDrop; property OnDockOver: TDockOverEvent read FOnDockOver write FOnDockOver; @@ -1857,6 +1859,9 @@ end. { ============================================================================= $Log$ + Revision 1.167 2004/01/07 18:05:46 micha + add TWinControl.DoubleBuffered property which is a hint for the interface to do double-buffering for this control + Revision 1.166 2004/01/03 23:14:59 mattias default font can now change height and fixed gtk crash diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index 273ab89cb9..479ce544b5 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -179,32 +179,42 @@ Var // create a paint message AWinControl := TWinControl(OwnerObject); - DC := Windows.GetDC(0); - GetWindowSize(Window, MemWidth, MemHeight); - MemBitmap := Windows.CreateCompatibleBitmap(DC, MemWidth, MemHeight); - Windows.ReleaseDC(0, DC); - MemDC := Windows.CreateCompatibleDC(0); - OldBitmap := Windows.SelectObject(MemDC, MemBitmap); + if AWinControl.DoubleBuffered then + begin + DC := Windows.GetDC(0); + GetWindowSize(Window, MemWidth, MemHeight); + MemBitmap := Windows.CreateCompatibleBitmap(DC, MemWidth, MemHeight); + Windows.ReleaseDC(0, DC); + MemDC := Windows.CreateCompatibleDC(0); + OldBitmap := Windows.SelectObject(MemDC, MemBitmap); + PaintMsg.DC := MemDC; + end; GetLclClientOriginOffset(AWinControl.Handle, LeftOffset, TopOffset); try DC := Windows.BeginPaint(Window, @PS); - AWinControl.EraseBackground(MemDC); PaintMsg.Msg := LM_PAINT; - PaintMsg.DC := MemDC; PaintMsg.PaintStruct := @PS; - MoveWindowOrgEx(MemDC, LeftOffset, TopOffset); + if not AWinControl.DoubleBuffered then + PaintMsg.DC := DC; + AWinControl.EraseBackground(PaintMsg.DC); + MoveWindowOrgEx(PaintMsg.DC, LeftOffset, TopOffset); DeliverMessage(OwnerObject, PaintMsg); - MoveWindowOrgEx(MemDC, -LeftOffset, -TopOffset); - Windows.BitBlt(DC, 0, 0, MemWidth, MemHeight, MemDC, 0, 0, SRCCOPY); + MoveWindowOrgEx(PaintMsg.DC, -LeftOffset, -TopOffset); + if AWinControl.DoubleBuffered then + Windows.BitBlt(DC, 0, 0, MemWidth, MemHeight, MemDC, 0, 0, SRCCOPY); Windows.EndPaint(Window, @PS); finally - SelectObject(MemDC, OldBitmap); - Windows.OpenClipboard(0); - Windows.EmptyClipboard; - Windows.SetClipboardData(CF_BITMAP, MemBitmap); - Windows.CloseClipboard; - DeleteDC(MemDC); - DeleteObject(MemBitmap); + if AWinControl.DoubleBuffered then + begin + SelectObject(MemDC, OldBitmap); +// for debugging purposes: copy rendered bitmap to clipboard +// Windows.OpenClipboard(0); +// Windows.EmptyClipboard; +// Windows.SetClipboardData(CF_BITMAP, MemBitmap); +// Windows.CloseClipboard; + DeleteDC(MemDC); + DeleteObject(MemBitmap); + end; end; end; @@ -928,6 +938,9 @@ end; { $Log$ + Revision 1.86 2004/01/07 18:05:46 micha + add TWinControl.DoubleBuffered property which is a hint for the interface to do double-buffering for this control + Revision 1.85 2004/01/03 21:06:06 micha - fix win32/checklistbox - implement proper lcl to interface move/size notify via setwindowpos