Obtaining screen dimensions lazarus / 31-LCL ---------------------------------------------------------------------- howardpc · 2022-10-28 05:38 My Windows laptop reports Screen.PixelsPerInch as 96 and Width as 1920, Height as 1080. This would indicate that the screen width is 1920/96=20" and height is 1080/96=11.25". I've never seen a laptop that big. With HighDPI the PixelsPerInch is a higher figure than 96. Working from my actual screen dimensions the value must be about 126. Does the LCL have a way to determine screen dimensions in inches (or cm), and can it provide the actual HighDPI value(s) in use? ---------------------------------------------------------------------- SymbolicFrank · 2022-10-28 06:08 96 is simply the default setting. There are multiple ways to query the capabilities of a screen, which are often not very well supported by the screens themselves. Edit: ok, not very helpful. Next time, I'll spend more effort on answering. But is is already covered below. ---------------------------------------------------------------------- dsiders · 2022-10-28 06:10 Quote from: howardpc on October 28, 2022, 07:38:44 amMy Windows laptop reports Screen.PixelsPerInch as 96 and Width as 1920, Height as 1080. This would indicate that the screen width is 1920/96=20" and height is 1080/96=11.25". I've never seen a laptop that big. With HighDPI the PixelsPerInch is a higher figure than 96. Working from my actual screen dimensions the value must be about 126. Does the LCL have a way to determine screen dimensions in inches (or cm), and can it provide the actual HighDPI value(s) in use? TScreen has a Monitors property. Those items (TMonitor) have a PixelsPerInch property. So... 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 Screen.Monitors[n].PixelsPerInch There is also TScreenInfo / ScreenInfo in the graphics unit. ---------------------------------------------------------------------- KodeZwerg · 2022-10-28 06:19 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 var  FRect: TRect;begin  FRect.Left      := GetSystemMetrics(SM_XVIRTUALSCREEN);  FRect.Top       := GetSystemMetrics(SM_YVIRTUALSCREEN);  FRect.Right  := GetSystemMetrics(SM_CXVIRTUALSCREEN);  FRect.Bottom := GetSystemMetrics(SM_CYVIRTUALSCREEN);On windows this is a reliable way to quick get dimensions of all connected displays. ---------------------------------------------------------------------- 440bx · 2022-10-28 06:58 Quote from: howardpc on October 28, 2022, 07:38:44 amMy Windows laptop reports Screen.PixelsPerInch as 96 and Width as 1920, Height as 1080. This would indicate that the screen width is 1920/96=20" and height is 1080/96=11.25". I've never seen a laptop that big. TTBOMK, getting the real/actual screen/monitor size is not particularly easy and a bit of a hit and miss proposition.  The closest thing to something that works seems : https://ofekshilon.com/2014/06/19/reading-specific-monitor-dimensions/ The code is in C but, it doesn't look like it would be hard to port to Pascal. HTH. ---------------------------------------------------------------------- howardpc · 2022-10-28 07:04 Thanks for your replies. Unfortunately, apart from 440bx's solution, all your solutions still use a PixelsPerInch value of 96, so are useless for getting accurate screen dimensions on high DPI displays. Unfortunately also, my C skills are not up to transposing the (Windows only) C code 440bx quotes. Could anyone help me out with a Pascal version? ---------------------------------------------------------------------- KodeZwerg · 2022-10-28 07:16 dimension and ppi has somehow nothing to do together. dimension is the hardware, ppi is the software, so what you want to do may i ask? ---------------------------------------------------------------------- MarkMLl · 2022-10-28 07:48 There was a thread on this a couple of weeks ago. The bottom line is that while a laptop may be better than a desktop, if the monitor doesn't report its characteristics truthfully to the BIOS and OS then application software can only guess. MarkMLl ---------------------------------------------------------------------- SymbolicFrank · 2022-10-28 09:49 If you want to know how large to display things, like the UI, the DPI+size is only part of the story. You also want to know the viewing distance, and that is often really hard to determine. And for bonus points: the age of the viewer. ---------------------------------------------------------------------- howardpc · 2022-10-28 10:05 The viewing distance is indeed critical. The software I am working on requires the viewer to try to maintain a steady distance of 57 cm, and also asks the viewer's age. Of course, both factors might be ignored or spoofed. ---------------------------------------------------------------------- dbannon · 2022-10-28 11:43 Quote from: howardpc on October 28, 2022, 12:05:43 pm and also asks the viewer's age. You should cut the user in half and count the rings  .. no, wait, thats trees ! Seriously, hi DPI is usually scaled so it works with existing applications without becoming tiny - see https://wiki.gnome.org/HowDoI/HiDpi Davo ---------------------------------------------------------------------- SymbolicFrank · 2022-10-28 13:07 I use a 43" 4K TV as monitor for playing games and such. But my viewing distance is ~100 cm, so your application wouldn't work for me But yes, it's mostly a problem with phones and pads. ---------------------------------------------------------------------- howardpc · 2022-11-09 14:24 For a Windows-only solution that gives accurate screen dimensions in cm whatever the HDPI, see this thread by domasz which uses the WinAPI call EnumDisplayDevicesAEx.