If I create a simple app with a paint box and a scroll bar, draw some rectangles in the paint box, and make the scroll bar change refresh the paint box, I get a flicker free display when I drag the scrollbar (with DoubleBuffer set on the form):
procedure TMainForm.OnHorzChange(Sender: TObject);
begin
PaintBox.Refresh;
end;
procedure TMainForm.OnPaint(Sender: TObject);
var
x, y: integer;
begin
with PaintBox.Canvas do
begin
Pen.Color := clBlack;
Brush.Color := clGray;
for y := 0 to 9 do
for x := 0 to 9 do
Rectangle(x * 32, y * 32, x * 32 + 24, y * 32 + 24);
end;
end;
If I then change appearance to Carbon, the flicker returns:
program test;
uses
Vcl.Forms,
main in 'main.pas' {MainForm},
Vcl.Themes,
Vcl.Styles;
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
TStyleManager.TrySetStyle('Carbon');
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
So how can I use appearance and not get flickering? The setting double buffer on the main window doesn't stop the flickering.
Put your
PaintBox
on theTPanel
and setPanel.ParentBackground
to False. In this case it does not flicker for me.