05-25-2022, 08:05 PM
(This post was last modified: 05-25-2022, 08:09 PM by DEKETO.
Edit Reason: needed to add text
)
(05-14-2022, 09:23 PM)Alexandre Machado Wrote: I suppose you are referring to this demo?
https://github.com/Atozed/IntraWeb/tree/...lCentering
Hi Alexandre,
Yes, I have tried that demo and it works under certain circumstances and fails under others. Here is what I did:
I downloaded the demo, then widened IWRegion1 to 800 pixels, moved it to position left = 24 (same as IWMemo1), and then added two TIWLabels to it to mark the top left and bottom right corners. I made no other changes, and got the following results:
1. In the first screenshot, I ran it with my browser window maximized. Everything is properly centered.
2. In the second screenshot, I have resized my browser window to its minimum width (500 pixels). IWRegion1 is still centered, but as you can see the left side is cut off even though the window is scrolled all the way to the left. There is no way to scroll left to see that part of the IWRegion1, and so this obviously is useless.
So at this point I modified the CenterControlInParent procedure by adding the line "if x < 24 then x := 24;" prior to the AControl.SetBounds call. Theoretically, this should set the left position of IWRegion1 to 24 any time the browser window is less than 848 pixels wide, but it does not do this at all. Here is what happens:
3. If the initial size of the browser window is sufficiently large (848 pixels or wider), everything behaves exactly as in 1. and 2. above. In other words, IWRegion1 will stay centered, but oddly, if the browser window is shrunk smaller than IWRegion1 (say, to 500 pixels), IWRegion1 does NOT anchor at left position 24, but instead gets cut off at the left with no way to scroll to it.
4. If the initial size of the browser window is sufficiently small (less that 848 pixels wide), we get the results shown in the third screenshot (500 pixels wide). Clearly, IWRegion1 is NOT centered, nor is is positioned at the (expected) left position of 24 pixels. If we then maximize the browser window as seen in the fourth screenshot, you can see that IWRegion1 moves even further right - obviously not centered, nor what we want or expect.
The only thing I have been able to determine is that it looks to me like perhaps AControl.Parent.Width does NOT report the true width of the browser window itself, but rather the width that Delphi thinks the form should be. So if IWRegion1 is 800 pixels wide and is sitting at left = 24 and the browser window then opens with a width of 500 pixels, AControl.Parent.Width reports back a width of 824 instead of 500, which of course would throw off the centering math, yet even that doesn't match up with the observed behavior.
Perhaps you can replicate this on your end? I'm stumped. It seems like this should be so simple......
Thanks for your help!!!
George

