Win32: disable auto-DoubleBuffered on themed native controls that have animations. Issue #33832

git-svn-id: trunk@58155 -
This commit is contained in:
ondrej 2018-06-06 14:05:31 +00:00
parent d4d9b75c39
commit 85a2f5309e
7 changed files with 19 additions and 38 deletions

View File

@ -655,12 +655,6 @@ begin
Result := (AIndex <> -1) and (AIndex <> ACurIndex);
end;
class function TWin32WSCustomTabControl.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32ThemedDoubleBuffered(AWinControl);
end;
class procedure TWin32WSCustomTabControl.SetTabSize(
const ATabControl: TCustomTabControl;
const ATabWidth, ATabHeight: integer);

View File

@ -87,7 +87,7 @@ function GetLCLClientBoundsOffset(Handle: HWnd; out Rect: TRect): boolean;
procedure LCLBoundsToWin32Bounds(Sender: TObject; var Left, Top, Width, Height: Integer);
procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt);
procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer);
function GetWin32ThemedDoubleBuffered(Sender: TWinControl): boolean;
function GetWin32NativeDoubleBuffered(Sender: TWinControl): boolean;
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
@ -784,12 +784,12 @@ begin
Top := winRect.Top - parRect.Top;
end;
function GetWin32ThemedDoubleBuffered(Sender: TWinControl): boolean;
function GetWin32NativeDoubleBuffered(Sender: TWinControl): boolean;
begin
// force double buffering when themes are enabled and there is no remote session
// disable auto-DoubleBuffered to allow animations, see #33832
Result :=
Sender.DoubleBuffered
or (ThemeServices.ThemesEnabled and (GetSystemMetrics(SM_REMOTESESSION)=0));
Sender.DoubleBuffered
and not(ThemeServices.ThemesEnabled and (Application.DoubleBuffered=adbDefault) and Sender.ParentDoubleBuffered);
end;
{

View File

@ -9,9 +9,3 @@
}
{ TWin32WSCustomTreeView }
class function TWin32WSCustomTreeView.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32ThemedDoubleBuffered(AWinControl);
end;

View File

@ -65,7 +65,6 @@ type
class procedure RemovePage(const ATabControl: TCustomTabControl;
const AIndex: integer); override;
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
class function GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer; override;
@ -97,7 +96,6 @@ type
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
class procedure SetSizeGrip(const AStatusBar: TStatusBar; SizeGrip: Boolean); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
@ -263,7 +261,6 @@ type
TWin32WSCustomTreeView = class(TWSCustomTreeView)
published
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
end;
{ TWin32WSTreeView }
@ -489,12 +486,6 @@ begin
end;
end;
class function TWin32WSStatusBar.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32ThemedDoubleBuffered(AWinControl);
end;
class function TWin32WSStatusBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var

View File

@ -209,8 +209,8 @@ end;
function RegisterCustomTreeView: Boolean; alias : 'WSRegisterCustomTreeView';
begin
RegisterWSComponent(TCustomTreeView, TWin32WSCustomTreeView);
Result := True;
//RegisterWSComponent(TCustomTreeView, TWin32WSCustomTreeView);
Result := False;
end;
// calendar

View File

@ -41,19 +41,12 @@ type
class procedure SendCharToEditor(AEditor:TWinControl; Ch: TUTF8Char); override;
class function GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; override;
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
end;
implementation
{ TWin32WSCustomGrid }
class function TWin32WSCustomGrid.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32ThemedDoubleBuffered(AWinControl);
end;
class function TWin32WSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect;
var

View File

@ -257,6 +257,7 @@ type
published
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetDoubleBuffered(const AWinControl: TWinControl): Boolean; override;
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
class procedure SetShortCut(const AButton: TCustomButton; const ShortCutK1, ShortCutK2: TShortCut); override;
end;
@ -441,7 +442,7 @@ begin
WM_ERASEBKGND:
begin
Control := GetWin32WindowInfo(Window)^.WinControl;
if not Control.DoubleBuffered then
if not TWSWinControlClass(Control.WidgetSetClass).GetDoubleBuffered(Control) then
begin
LMessage.msg := Msg;
LMessage.wParam := WParam;
@ -1782,7 +1783,7 @@ begin
WM_ERASEBKGND:
begin
Control := GetWin32WindowInfo(Window)^.WinControl;
if not Control.DoubleBuffered then
if not TWSWinControlClass(Control.WidgetSetClass).GetDoubleBuffered(Control) then
begin
LMessage.msg := Msg;
LMessage.wParam := WParam;
@ -1819,6 +1820,12 @@ begin
Result := Params.Window;
end;
class function TWin32WSButton.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32NativeDoubleBuffered(AWinControl);
end;
class procedure TWin32WSButton.SetDefault(const AButton: TCustomButton; ADefault: Boolean);
var
WindowStyle: dword;
@ -1853,6 +1860,7 @@ begin
with Params do
begin
pClassName := @ButtonClsName[0];
SubClassWndProc := @ButtonWndProc;
WindowTitle := StrCaption;
end;
// create window
@ -1863,7 +1871,7 @@ end;
class function TWin32WSCustomCheckBox.GetDoubleBuffered(
const AWinControl: TWinControl): Boolean;
begin
Result := GetWin32ThemedDoubleBuffered(AWinControl);
Result := GetWin32NativeDoubleBuffered(AWinControl);
end;
class procedure TWin32WSCustomCheckBox.GetPreferredSize(const AWinControl: TWinControl;
@ -1971,6 +1979,7 @@ begin
with Params do
begin
pClassName := @ButtonClsName[0];
SubClassWndProc := @ButtonWndProc;
WindowTitle := StrCaption;
end;
// create window