Cross Platform Form Height lazarus / 31-LCL ---------------------------------------------------------------------- VTwin · 2021-05-24 19:05 I develop on Windows, Mac, and Linux. The Anchor Editor is very helpful in placing controls. However, selecting a Form height that works on all platforms is challenging, as the Form bottom can not be anchored to a contained control. Currently I use a class that determines the bottom of the lowest control, typically an OK button, and then set the Form Height to that plus a margin. This is done in the OnShow handler and works pretty well, but seems a bit of a kludge. I wonder if I am missing something obvious. ---------------------------------------------------------------------- winni · 2021-05-24 19:38 Hi! No, you dont overlook something obvious. For this item I am not up to date, but there were times when in Linux Form.Height was the same as client.height.  So you needed the height of the TitleBar. That could be retrieved with this hack: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TitleBarHeight (Form: TForm) : Integer;var ws : TWindowState;    oldheight : integer;    count : integer = 0;beginws := Form.WindowState;if ws <> wsMaximized then  begin   oldHeight := Form.Height;   Form.WindowState := wsMaximized;   repeat   Application.ProcessMessages; // let Form expand   // but one ProcessMessages may be not enough!   inc (Count);   until (Form.Height<>oldHeight) or (count >= 10);   end;result := Form.Monitor.WorkAreaRect.Height -Form.Height;if ws <> wsMaximized then  begin  Form.WindowState := ws; // and back again  Application.ProcessMessages;  end;end; Winni ---------------------------------------------------------------------- VTwin · 2021-05-24 20:06 I don't currently have a problem with the TitleBar height, possibly a few years back if I recall. It is even more difficult dealing with WinControls, such as PageControls. I wrote a procedure to get the maximum control bottom, looping through all the TabSheets, but it is not working well. Currently I'm just checking them on all platforms and calling it "good enough" if all the controls are visible. Linux usually requires the most space. It would be nice to have a general solution that could adjust a WinControl height to enclose all controls, but perhaps that does not exist. ---------------------------------------------------------------------- winni · 2021-05-24 20:14 Hi! Hack around the world: Leave a space of let's say 10 Pixel to the borders. That must be enogh. You can make a nice decoration for this border. Or for testing reasons a pixel meter: a short line at every second pixel and a long one at 10 pixel from the border. Winni PS.: With a PageControl and some Tabsheets there are at least with Linux some Pixels in the Nirvana. ---------------------------------------------------------------------- VTwin · 2021-05-24 21:30 For a PageControl, you have to account for ShowTabs, if true this adds additional pixels... ---------------------------------------------------------------------- winni · 2021-05-24 21:56 Quote from: VTwin on May 24, 2021, 11:30:22 pmFor a PageControl, you have to account for ShowTabs, if true this adds additional pixels... Hi! Yes I know. But you should not have brought me to the crazy idea to use a PageConrol without tabs. Never did that before. Suddenly appears a mini bug: Exact at the x-position where before the now disabled Tab should appear, the image on the tabsheet is erased. Only on startrup.  Not a big problem because a invalidate does the job, but .... Proof in attachment. I return quick back to enable the tabs before more bugs appear .... Winni ---------------------------------------------------------------------- trev · 2021-05-24 23:02 I've been compiling an application for macOS, Linux, Windows and FreeBSD and just use an IFDEF for form height for each OS. Simples ---------------------------------------------------------------------- VTwin · 2021-05-25 01:21 Quote from: trev on May 25, 2021, 01:02:43 amI've been compiling an application for macOS, Linux, Windows and FreeBSD and just use an IFDEF for form height for each OS. Simples Thanks. That works, if not elegant. I've got dozens of dialogs, so it is cumbersome. For dialogs without PageControls, my solution works ok, so perhaps I can limit this to the few that contain PageControls. ---------------------------------------------------------------------- VTwin · 2021-05-27 14:16 @Winni I have a PageControl with about 25 TabSheets. They are selected using a TreeView instead of tabs, like the Lazarus IDE Options dialog, so I hide the tabs.