1

Whenever I draw on the form/on a image or when I change the position of a element(eg. button) the form flashes briefly after which it shows properly. This bug occurs with all apps I made and I have yet to find a solution.

Flashing Bug

Anything from Button1.Left=100 to Form1.Canvas.Ellipse(10,10,40,40) causes this effect to occur.

I assume this has to do something with the form recalculating what to show on it?

Example:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.GIFImg;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Image1.Left:=Image1.Left+1;
end;

end.

This is a simple example. When the image moves for a reason it flashes

Codex
  • 101
  • 1
  • 11
  • Please add [mcve] There are many reasons why this can happen. Also Delphi version you use and visual framework (VCL, FMX) can also be of importance. – Dalija Prasnikar Oct 23 '21 at 07:21
  • I tried your simple example, and it does not flicker. Do you have some more code in the form where you have the problem ? I tried with Delphi 7 – GuidoG Oct 23 '21 at 07:48
  • Enter in the search box for this site: `[delphi] [vcl] flicker` and you will get a number of actions to apply to your case, depending on what the case is. – Tom Brunberg Oct 23 '21 at 09:08
  • 3
    You should NOT make animations by moving around VCL controls. Instead, you should paint the animation manually on a canvas (such as a window) using GDI, GDI+, OpenGL, or DirectX. Here's my standard example: https://stackoverflow.com/a/7224075/282848 – Andreas Rejbrand Oct 23 '21 at 09:35

0 Answers0