Search code examples
animationiconsflickertlistview

lazarus/FPC: TListView repaints row if only the icon changes


Hi Lazarus/LCL/FPC experts,

just for fun I have tried to make a TListView Icon spin. On my test form I have a lone TListView (ViewStyle := vsReport, RowSelect := true), and I added a bunch of images to my SmallImages list, the images [0] .. [5] contain the pictures of my rotating symbol. To check things out I let the symbol spin using a timer:

procedure TForm1.Timer1Timer(Sender: TObject);
   begin
     if ListView1.Selected<>NIL then
        ListView1.Selected.ImageIndex:=(ListView1.Selected.ImageIndex + 1) mod 5;
   end;

The timer is set to 200ms, the principle works well, the icon of the selected row does indeed spin. But it seems like the LCL Listview redraws the whole row, not only the icon image, this letting the whole selected row flicker.

Does anyone know a way to reduce the flicker? I'd already be happy if the ListView wouldn't redraw the whole row, but only the image.

Thx, Armin.


Solution

  • Found the solution myself. The flicker seems to be related to graphics card driver issues, and affected my development machine only. The program has seens many other machines since, no flicker, and since it is out in the wild now ... no flicker effect has ever been reported by any of the testers or users.

    So I guess it is an issue with my specific programming environment.

    Armin.