Hello there!
For a small personal project I created an application that basically displays a SQLite database with a few bells and whistles. I was happy with how it worked and performed until I realized that one specific element of the application seems to be quite slow on lower end systems:
My database contains a column which contains relative paths to image files.
row | title | cover |
1 | 2020-01-01_Morning | path/to/cover.png |
2 | 2020-01-02_Evening | path/to/cover.jpeg |
I use a TImage to display the image files from the mentioned column and update the image file through
AfterScroll:
procedure TForm1.SQLQuery1AfterScroll();
begin
cover:=DBGrid1.DataSource.DataSet.Fields[2].value;
coverImage.Picture.LoadFromFile(cover.ToString());
end
On a modern system scrolling through the database is fluent but on an older system it's sluggish. I guess that's because scrolling through the database goes through every row and executes the AfterScroll procedure every time. So if I were to quickly scroll through 10 rows of the database it would execute the procedure 10 times. Now I'm looking for a way to solve this problem. Maybe there's a way to "defer" the execution of the AfterScroll procedure to only run after a row is active for more than 500ms or something like that?
I'd be very thankful for tips on how to improve performance here.
Regards
Fred