LCL Windows: TForm1.Height (and also .Width) wrong ? lazarus / 31-LCL ---------------------------------------------------------------------- PeterX · 2016-09-23 10:26 Hi all, this works in Delphi (but not in Lazarus): 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 SetBounds( 0, 0, Self.Width, Screen.Height -GetTaskBarHeight); this works in Lazarus: 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 SetBounds( 0, 0, Self.Width, Screen.Height -GetTaskBarHeight -44); Somewhere 44 pixels get lost in LCL ..  Please see example project, appended. fn GetTaskBarHeight() is included in the ZIP file. ---------------------------------------------------------------------- rvk · 2016-09-23 11:06 I don't see the same... Attached is your code on my machine. (I'm missing those 44 pixels at the bottom) The GetTaskBarHeight returns 40 for me (on both Lazarus and Delphi XE). (What does it return for you on Lazarus and Delphi 5 ??) ---------------------------------------------------------------------- rvk · 2016-09-23 11:09 Maybe it's a problem with your DPI-settings. Mine is at 100%. If I execute this on a (virtual)machine with DPI set at 150% I get attached image. ---------------------------------------------------------------------- PeterX · 2016-09-23 11:19 Quote from: rvk on September 23, 2016, 01:06:13 pmThe GetTaskBarHeight returns 40 for me (on both Lazarus and Delphi XE). (What does it return for you on Lazarus and Delphi 5 ??) My TaskBarHeight  here on the job is 48, with Windows 7 and 125 % At home with Windows 10 it's also 48 (I think, also 125% ..) ---------------------------------------------------------------------- PeterX · 2016-09-23 11:22 Quote from: rvk on September 23, 2016, 01:09:38 pmMaybe it's a problem with your DPI-settings. Mine is at 100%. Under Delphi I have no problem. There the bottom of the form exactly matches the top border of the TaskBar. Independent of scaling by windows. Same code under Lazarus, and my Form (here on the job) is 44 pixel higher, so Form goes under the Windows Taskbar. When I  code -44 the form bottom matches the Taskbar Top. ---------------------------------------------------------------------- PeterX · 2016-09-23 11:32 Diff was wrongly shown, new attachment. Self.Height says 1348 but the form bottom exactly matches TaskBar Top at 1392 This makes a gap of 44 pixel .. here on this PC ---------------------------------------------------------------------- PeterX · 2016-09-23 11:34 2016-09-23 Windows Taskbar Size 02.zip ---------------------------------------------------------------------- rvk · 2016-09-23 12:30 First thing to realize is that you should never... and I mean NEVER work with constant numbers when dealing with screen sizes. When you settle on -44, it will be something else on another system or Windows version. You can see that by running your example in Windows XP, 7 and 10. Even changing the Theme to classic makes a difference. Second... it's better to use Monitor.WorkareaRect or Screen.WorkAreaRect. It uses the call to SPI_GETWORKAREA to get the exact workarea minus the taskbars. You should also not use top=0 but top=workareatop because your taskbar could also be at the top of the screen. And have you thought about the taskbar at the left or right edge of the screen? Even when working with WorkareaRect I get on Windows 10 a small gap. That's because Windows 10 doesn't show the form-borders. Do you want to solve this? You could use SM_CXSIZEFRAME and SM_CYSIZEFRAME to get the (invisible) border-sizes and add it to fill in the gap. After all that... I do see some weirdness when setting TForm.Height in Lazarus. Even with 100% I get 1160 for WorkArea (which is correct 1200-40) but setting 1160 gives a too large form. There is a know design "issue" where Form.ClientWidth = Form.Width. It's discussed in the following topic: https://forum.delphi-treff.de/index.php/Thread/59694-TForm- ClientHeight-TForm-Height-und-TForm-ClientWidth-TForm-Width/ So you could use the topic from that topic: 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 uses UnitWorkAroundLazarusBugFormWidthAndHeight; // download from that topic//...SetTrueFormHeight(Self, Screen.WorkAreaHeight);That still gives me a gap on Windows 10 but that's also true on Delphi. Using this fixes that but you'll have to check if you're on Windows 10. 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 SetTrueFormHeight(Self, Screen.WorkAreaHeight + GetSystemMetrics(SM_CYSIZEFRAME)); Some constants from Windows to use instead of hard values: https://msdn.microsoft.com/en- us/library/windows/desktop/ms724385(v=vs.85).aspx ---------------------------------------------------------------------- PeterX · 2016-09-23 13:48 Quote from: rvk on September 23, 2016, 02:30:24 pmAnd have you thought about the taskbar at the left or right edge of the screen? Yes. Please see source code example, unit1.pas, line 5 .. 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 // Hint:  This is a simple example and does NOT take into account//        that the taskbar might NOT be at the bottom of the screen !////        => please see  ABE_BOTTOM - ABE_TOP - ABE_LEFT - ABE_RIGHT ---------------------------------------------------------------------- PeterX · 2016-09-23 14:16 Quote from: rvk on September 23, 2016, 02:30:24 pmFirst thing to realize is that you should never... and I mean NEVER work with constant numbers when dealing with screen sizes. When you settle on -44, it will be something else on another system or Windows version. Please apologize, this is example code for the forum, no real application. I tried to keep it as simple as possible to point out the problem. Quote from: rvk on September 23, 2016, 02:30:24 pmIt's better to use Monitor.WorkareaRect or Screen.WorkAreaRect. It uses the call to SPI_GETWORKAREA to get the exact workarea minus the taskbars. I'll go into it. Quote from: rvk on September 23, 2016, 02:30:24 pmThere is a know design "issue" where Form.ClientWidth = Form.Width. It's discussed in the following topic: https://forum.delphi-treff.de/index.php/Thread/59694-TForm- ClientHeight-TForm-Height-und-TForm-ClientWidth-TForm-Width/ This is good reasons why the Delphi 5 never made trouble. The WidgetSet thing surely makes lots of overhead. Thanks a lot for Your help ! ---------------------------------------------------------------------- PeterX · 2016-09-23 16:28 Hacked around, now it nearly fits .. But no warranty that this really makes sense ..