How to access screen display’s DPI settings via javascript? [duplicate]

Looks like you can use the ‘screen’ DOM object in IE, its got properties for deviceXDPI, deviceYDPI, logicalXDPI, logicalYDPI. https://www.w3schools.com/jsref/obj_screen.asp Here’s a solution from http://www.webdeveloper.com/forum/showthread.php?t=175278 (i havent tried it, seems like a total hack 🙂 Just create something 1 inch wide and measure it in pixels! console.log(document.getElementById(“dpi”).offsetHeight); #dpi { height: 1in; left: -100%; position: absolute; … Read more

Detecting the system DPI/PPI from JS/CSS?

<div id=’testdiv’ style=”height: 1in; left: -100%; position: absolute; top: -100%; width: 1in;”></div> <script type=”text/javascript”> var devicePixelRatio = window.devicePixelRatio || 1; dpi_x = document.getElementById(‘testdiv’).offsetWidth * devicePixelRatio; dpi_y = document.getElementById(‘testdiv’).offsetHeight * devicePixelRatio; console.log(dpi_x, dpi_y); </script> grabbed from here http://www.infobyip.com/detectmonitordpi.php. Works on mobile devices! (android 4.2.2 tested)

How to set the DPI of Java Swing apps on Windows/Linux?

I’m currently investigating this issue on Windows. Here’s what I found: Most Swing Look & Feels don’t support high DPI at all, not even Nimbus even though it’s supposed to be scalable. I found some old blog posts saying that Nimbus might eventually offer high DPI scaling, but apparently that never happened. The one exception … Read more

How can I get the DPI in WPF?

https://learn.microsoft.com/en-us/archive/blogs/jaimer/getting-system-dpi-in-wpf-app seems to work PresentationSource source = PresentationSource.FromVisual(this); double dpiX, dpiY; if (source != null) { dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11; dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22; }

Creating a DPI-Aware Application

EDIT: As of .NET 4.7, windows forms has improved support for High DPI. Read more about it on learn.microsoft.com It only works for Win 10 Creators Update and higher though, so it might not be feasible to use this yet depending on your user base. Difficult, but not impossible. Your best option is to move … Read more

How to get Windows Display settings?

Both graphics.DpiX and DeviceCap.LOGPIXELSX return 96 on Surface Pro in all scaling levels. Instead, I managed to calculate the scaling factor this way: [DllImport(“gdi32.dll”)] static extern int GetDeviceCaps(IntPtr hdc, int nIndex); public enum DeviceCap { VERTRES = 10, DESKTOPVERTRES = 117, // http://pinvoke.net/default.aspx/gdi32/GetDeviceCaps.html } private float getScalingFactor() { Graphics g = Graphics.FromHwnd(IntPtr.Zero); IntPtr desktop = … Read more

How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?

Once you go past 100% (or 125% with the “XP-style DPI scaling” checkbox ticked), Windows by default takes over the scaling of your UI. It does so by having your app render its output to a bitmap and drawing that bitmap to the screen. The rescaling of that bitmap makes the text inevitably look fuzzy. … Read more

How to write WinForms code that auto-scales to system font and dpi settings?

Controls which do not support scaling properly: Label with AutoSize = False and Font inherited. Explicitly set Font on the control so it appears in bold in the Properties window. ListView column widths don’t scale. Override the form’s ScaleControl to do it instead. See this answer SplitContainer‘s Panel1MinSize, Panel2MinSize and SplitterDistance properties TextBox with MultiLine … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)