I noticed in one of my test applications after I have added so many TPanels to a TScrollBox I run into a problem with the ones drawn past that certain amount. I disable the scroll box prior to drawing and it is always cleared before drawing so there are no relative position problems. Initially I thought maybe I had run into some sort of maximum height to paint. So you know the arrangement is width occupying panels stacked vertically.
So I created a new project to try and identify and tackle the problem and it has revealed an additional detail to the problem. When I'm home I can provide the example and a video but I will describe for now. Made a form with a TScrollBox a spinedit to specify how many panels a button to create the panels in a loop and a button to free the panels and empty the array for another try. I set the caption to the number in the loop for identification.
I have tried 2 ways of stacking to see if bit mattered. One is to set the position I times height so if height is 200 then i * 202 giving it a space of 2px. The new way I tried was using align top instead. It might have a slight difference in effect but the problem in general is still the same.
The new problem is with the scroll range. After the loop is done and the scroll box is enabled scrolling down to the bottom stops at the last numbered panel. But its out of place maybe 199 right below 169 its 200 panels. Then the scroll bar adjusts range letting me reach the bottom only to see the next to last panel 198. I believe this occurs using the align top method as it never occurred in my app. I will test further.
Bottom panel not placing aside I think the solution to that problem is to manually calculate and set the range.
The main problem which occurs in my app when setting the position instead of using align top is that after a certain number of panels they all position at the end in the same spot. Before a certain amount its fine say 50 or 100 but after so many it happens. I know 200 times 200 is a pretty small integer but maybe there is a address limit?
I will continue to test I still need to check if panel height adds into it. But figured this has to be a known issue. Delphi 2009 by the way.