@Martin_fr Yes, for example when i scroll the page down(and the images are going up) with the mouse wheel i feel like it's taking time to paint the bottom part of the appearing images whereas when i scroll using the scroll bar the bottom part appears watery so to speak
There is a way to make sure this does not happen (though I don't have the implementation details at hand / and not sure it can easily be done with panels).
That would be:
- don't scroll
- paint the entire background in one go with the newly offset-ed image(s).
What do you mean do not scroll? Everything should appear in the viewport at once. I don't like that.
Paint the entire background? How? I paint image by image by first checking if it's in view as you can see in the paint routine
I should have made it clear, that this is not a good replacement. Right now you have the "split screen" issue, where part is awaiting its paint... And the other part shows what had already been there, it was just scrolled (moved on the screen, without repaint) using ScrollWindowEx from the Win kernel.
If you don't use ScrollWindowEx => and instead paint the entire visible are with a single BltBitmap (using a fully prepared source bitmap), then you are always that fast, that you shouldn't get the split effect (o.k. in theory you can hit the screen refresh, and get tearing).
However full update every time is no good. It will be slow, really slow. It wont flicker, but it can easily start stuttering.
----
So the real question (and I don't have the answer) is why does it take that long to update.
The mouse wheel vs scrollbar is of interest. Because if it works with the scrollbar, then your paint method is fast enough.
Unless ...
if pb.hoveringItem <> nil then begin //hovering item
mi := pb.hoveringItem;
bmp := TBGRABitmap.Create(mi.width, mi.height, BGRA(5,5,120,90));//from 0 to 255, higher means more opaque//0,0,0,100
try
Maybe the hovering slows your paint down?
Actually that could be it.
I first though, bad idea to create new bitmaps in paint, better have prepared ones, that can be used. But maybe its not that.
Maybe it is still fast enough, maybe it would better be created outside paint, and kept -- not sure, you may need to try.
But there is another issue.
It looks like the image under the mouse is darkened? So it gets invalidated.
Each time an image gets invalidated, then that entire image needs repaint => Except, the actual repaint will be much more.
If you invalidate 2 small rects, then the area to repaint is the rectangle including both of them (and everything inbetween).
(WIthin one single WinControl, eg. one Panel)
So if you darken (and invalidate) an image in the upper half, and scrolling invalidates the entire width of the lower area (few pixels height, but full width), then the containing repaint rect, will be 80% of the screen. And that could slow think down, and the if a paint event took to long, all the scroll event get combined, do one big scroll before the next paint. And that might indeed flicker.