Recent

Author Topic: ScrollBox not scrolling all the way to the bottom  (Read 602 times)

Marion

  • Full Member
  • ***
  • Posts: 123
ScrollBox not scrolling all the way to the bottom
« on: December 05, 2022, 10:38:32 pm »
Has anyone else experienced this?

I have a tscrollbox to which I am dynamically adding tpanels. After about 40 panels, the scrollbox will not scroll all the way down to see the full last panel.

I am deleting the top most panel (Components[0].Free) to keep the number of child panels to a reasonable amount (no more than 30 child components) but that still doesn't help. The scrollbox keeps expanding the verticalscrollbar until it is too tall vertically and it errors.

The scrollbox seems to keep adding to the vertical scroll max and doesn't account for the fact that I have deleted off the top panels. If I reset the scrollbox by deleting all of the child components, it clears the problem and I can start adding controls against but I would rather no clear the scrollbox completely.

Anyone else have this? Any ideas how to fix this?
Thank you,
Marion
(A recovering Windows programmer.)

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: ScrollBox not scrolling all the way to the bottom
« Reply #1 on: December 05, 2022, 10:49:07 pm »
if the total height of all the panels is at 32678 or more, it stops.

It depends on where the last Panel is located.

The figure I quoted may even be a less of size.

The only true wisdom is knowing you know nothing

Marion

  • Full Member
  • ***
  • Posts: 123
Re: ScrollBox not scrolling all the way to the bottom
« Reply #2 on: December 06, 2022, 12:30:53 am »
if the total height of all the panels is at 32678 or more, it stops.

It depends on where the last Panel is located.

The figure I quoted may even be a less of size.

That gave me an idea so I did a test. I added code to give me a count of the number of child components in the scrollbox and a sum of their heights. At about 30 child components I start deleting the top components. I used componant.free and FreeAndNil(component). In both cases the number of child components and the total heights keeps going up BUT when I scroll to the top of the scrollbox, I only see 30 components.

I need a way to truly free the components and empty the garbage.
Thank you,
Marion
(A recovering Windows programmer.)

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: ScrollBox not scrolling all the way to the bottom
« Reply #3 on: December 06, 2022, 12:47:34 am »
Ok, Freeing components at the top isn't going to fix your client position problems.

If you have a component with a high Y location on the client, it will force you to scroll all the way at the bottom to see it.

  Removing components on top does not shuffle the lower ones up, the lower one's still maintained their Bounds Positions.

 Think of the client area, the area that you actually see in front of you regardless of scroll bars, is just a small portion of your actual client surface.
  The Window frame, the frame that contains the scrollbars act as a sliding portal to look at the client. It can only see as much of the client as its boundaries but that does not mean that's it for the client, the client still lives on beyond the edges if you have controls mapped out to boundaries outside that window Frame.


 So, if you want to shuffle up the lower controls you will need to change the boundaries of those controls to a smaller value on the Y axes.


The only true wisdom is knowing you know nothing

Marion

  • Full Member
  • ***
  • Posts: 123
Re: ScrollBox not scrolling all the way to the bottom
« Reply #4 on: December 06, 2022, 12:58:32 am »
Ok, Freeing components at the top isn't going to fix your client position problems.

If you have a component with a high Y location on the client, it will force you to scroll all the way at the bottom to see it.

  Removing components on top does not shuffle the lower ones up, the lower one's still maintained their Bounds Positions.

 Think of the client area, the area that you actually see in front of you regardless of scroll bars, is just a small portion of your actual client surface.
  The Window frame, the frame that contains the scrollbars act as a sliding portal to look at the client. It can only see as much of the client as its boundaries but that does not mean that's it for the client, the client still lives on beyond the edges if you have controls mapped out to boundaries outside that window Frame.


 So, if you want to shuffle up the lower controls you will need to change the boundaries of those controls to a smaller value on the Y axes.

I looked at what you said and this is what I find.

TControl(ScrollBox.Components[0]).Top = 0

TControl(ScrollBox.Components[ScrollBox.ComponentIndex]).Top = where it should be since each panel is 200 height.

So, that means there is an internal component that acts as the scrolling plane. When I free all of the child components then it resets to 0 as expected, but free them one at a time doesn't.

What are you recommending I do?
Thank you,
Marion
(A recovering Windows programmer.)

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: ScrollBox not scrolling all the way to the bottom
« Reply #5 on: December 06, 2022, 01:57:37 am »

 I think I am getting a better idea what you are doing and using the Components or Controls object isn't going to cut it.

 You need to have a controls list of your own where you can properly insert and remove items in the Boundary order not the creation order.
 
  When you remove a control from the control array or components array, more than likely the next one you add will end up at the bottom of the array, which is most like not where you want it.

 It's a thought but maybe you can explain a little more what you are trying to do.
The only true wisdom is knowing you know nothing

Marion

  • Full Member
  • ***
  • Posts: 123
Re: ScrollBox not scrolling all the way to the bottom
« Reply #6 on: December 06, 2022, 02:03:36 am »

 I think I am getting a better idea what you are doing and using the Components or Controls object isn't going to cut it.

 You need to have a controls list of your own where you can properly insert and remove items in the Boundary order not the creation order.
 
  When you remove a control from the control array or components array, more than likely the next one you add will end up at the bottom of the array, which is most like not where you want it.

 It's a thought but maybe you can explain a little more what you are trying to do.

Thank you for the help. I think I have a handle on what is going on. I think I'm going to write my own Scrollbox to fit my needs. Thanks again.
Thank you,
Marion
(A recovering Windows programmer.)

 

TinyPortal © 2005-2018