Concept of control placement in forms lazarus / 31-LCL ---------------------------------------------------------------------- MathMan · 2014-09-24 22:26 Hi all, I am currently using Lazarus 1.2.4, FPC 2.6.4 on Win 7/64 bit on an Intel processor. My concrete issue is that I would like to generate a form that contains a group box on the top left, a second Group box on the top right and a pair of Buttons ("OK" / "Cancel") on the bottom right. I understand that the sizes can be made self adjusting via AutoSize := TRUE for form and controls. What I am fiddling with is the positioning. I have read the form and control tutorials, scanned some sources that use specific controls but the General concept of placement via Align / Anchor / Top / Bottom / Left / Right etc. still eludes me. Can anyone pls. point me to some documentation about the conceptual idea (if exist) or a good source reference. Kind regards, MathMan ---------------------------------------------------------------------- taazz · 2014-09-24 22:53 Alignment: It is the notion of setting the control placement based on the general form position not specific it has 5 active value top, bottom, left, right and client, and two special none, custom. The idea of Alignment is to say that my main component that should occupy most of the users screen is my grid (alclient), on the left of the grid (alLeft) I want to have a list view with the possible filtering choices and at the top (alTop) a toolbar with all or most used commands for the data in the grid new, print, delete etc on the bottom a small memo that shows extra details for the selected row/column or both. When I have multiple control that I want on the left of my main focus (grid) I have two choices one I want to see them from left to right first the listbox occyping all the hight of the window then the second control occupying all the height as well then the grid etc.. IF I want to change how the controls are aligned to one an other ee the listbox must be on top of the second control with alleft allignment then I need to use a container eg a panel which will be aligned in alleft it will house the list and the second control with the list box in alClient mode and the second control in albottom since this is a container it can have its own focused control that will occupy most of the space in this case I choose the list box to be the focus of this container. same logic apply to all active values/positions. Anchors : The idea is that once a control is placed on the form you can choose how it behaves when the form is resized. If its anchored in one of its sides eg top no matter how the container isresized the top value of the control will not be changed. the same goes for the left too. For the bottom and right the rules are a bit different since there is no bottom or right property on the control but height and width when you set the bottom anchor to true you are asking from the container to maintain the same distance of the controls bottom to the containers bottom at all times so resizing the container will resize the control so the container.height - control.height produces the same result always (well kind of). If no anchor is specified then I think that the control is using some kind of percentage distance from the containers borders to move and keep the same percentage regardles of the container size. although they can both be set at the same and one does change the result of the position they are designed and coded separately and they don't need one another to work. If there is something more you need to know ask. ---------------------------------------------------------------------- MathMan · 2014-09-24 23:07 Quote from: taazz on September 25, 2014, 12:53:48 amAlignment: It is the notion of setting the control placement based on the general form position not specific it has 5 active value top, bottom, left, right and client, and two special none, custom.  ... ... If no anchor is specified then I think that the control is using some kind of percentage distance from the containers borders to move and keep the same percentage regardles of the container size. although they can both be set at the same and one does change the result of the position they are designed and coded separately and they don't need one another to work. If there is something more you need to know ask. Thanks Taazz - I think that this solves many of the questionmarks I had. To summarize from my side (and check if I got this right) - the positioning is done via a "divide and conquer" approach using panels for subdivision (I understand from the above that panels can also be iterated?!). Support for resizing is handled via the anchor settings and it would be good programming practice to keep positioning and resizing separate in my own code. Kind regards, MathMan ---------------------------------------------------------------------- Mike.Cornflake · 2014-09-25 08:47 While this topic looks solved, just leaving this here in case others need it. http://wiki.lazarus.freepascal.org/Autosize_/_Layout VERY long wiki article that one... ---------------------------------------------------------------------- MathMan · 2014-09-25 10:13 Quote from: Mike.Cornflake on September 25, 2014, 10:47:14 amWhile this topic looks solved, just leaving this here in case others need it. http://wiki.lazarus.freepascal.org/Autosize_/_Layout VERY long wiki article that one... YES!!! YMMD - that's exactly what I was looking for. Thanks a lot, MathMan