Forum > LCL

[solved--so far]Scrollbox -- why are controls not drawn in the order created?

<< < (3/3)

Martin_fr:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- Self.Align := alTop;  Self.Top := DTop; //High(SmallInt);
Have you tried swapping those 2 lines?

Having multiple alTop is always a bit dangerous. Afaik/IIRC, They are sorted by whatever "top" position they have before the alTop overrides the position, but then I don't know, if the next one is sorted according to the new Top of the already aligned one.... So you may have to set value to Top that are further out than expected.

The other thing to do is to do a DisableAllAutosing on the parent container before setting them.
Otherwise, if you do more than one, they will keep adjusting while you still are adjusting them => and that ain't no good.


Though I wonder, when you used/tried AnchorSide.Control... Did you remove the alTop then? Because if you didn't, then the alTop may take precedence. Otherwise the AnchorSide would force position (you then need to set the parent control as AnchorSide for Left/Right to have the width being done.

Having seen you access parent.controls[parent.controlcount-1] => Just the obvious remainder: You don't use any "BringToFront" or similar on the panels? Because afaik that changes there order in the list of Controls. (But again, not sure)

Martin_fr:
Not necessary related to your issue, but how many such sub-panels are you talking about?

Because if it is in the hundreds, you might get Windows to freak out. I did once a test with a plain form (non LCL, directly created via Windows API, so everything was Windows API only). I did put around 300 or 400 buttons or panels on that form.  And at some point Windows froze... It' long aga, but IIRC it froze completely (my entire Desktop) for maybe 10 secs. (That was Windows 10, not sure if other Versions do that do, or if it is still like that at all)... I don't recall the exact details, but Windows does have limits...

Martin_fr:
Just one more word on the auto-sizing (including align and all else)...

And it also depends on the parent having "AutoSize = True" or not.

Autosizing, aligning, positioning, .... are all always done immediately. You change the parent => autosize, you change the Top or Height => Autosize (of all others that may depend), you change anchors, or align ....

Unless you use DisableAutoSizing.

So when you have

--- Quote ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Self.Parent := AOwner as TWinControl;  Self.Align := alTop;  Self.Top := DTop; //High(SmallInt);
--- End quote ---

And say the Parent has "AutoSize = True"

Setting the parent, will set Top/Left = 0 => because an autosizing parent makes space...

Setting alTop, then makes this the topmost alTop (because Top=0). Actually it could also be the 2nd alTop from the top, as 2 controls would have "Top := 0".
The other panels will got down

"Self.Top = high(smallint)" should however work.... Good question. Though: assuming it is "visible = true". Not sure what happens if it is hidden. Might be skipped.

Though, again, I am not sure what happens with "top := " if align is already set. Yet, if you set it before it depends on the Parent.Autosize.


Beware, above is from distant memory. I probably got some details wrong. But it may be giving some ideas at what to pay attention....

indydev:
Wooh hoo! :D Tentative solution for now. 

Thank you Martin_fr for asking questions. I just kept messing with it.

If I remove Align:=alTop; altogether, set Left := 0;, set Width:=Parent.Width; and just handle the width adjustment in the @onPaint method I haven't been able to get the issue to arise after many attempts.

As for # of DiscussionPanels, I don't know how many a user may generate. The longest I have seen is about 100, but most sessions  are around 50 or less. I may have to put some code in to split sessions up when they get really long. As for controls in the Panels themselves, it is usually a RichMemo control, but could also include a button and a label if it needs a code window, or a table. The image on the left is just a stretchDraw on the Panel itself. So probably up to 4 controls on a panel.

Navigation

[0] Message Index

[*] Previous page

Go to full version