Windows缩放

Windows 8/10已经开始包含一个滑块,用于缩放多lessGUI元素,右键单击桌面 – >显示。 对于拥有4k屏幕笔记本电脑的同事来说,这是250%,而另一位同事在4k 28“屏幕上使用相同的分辨率则是150%。

如何以编程方式读取该值? 我需要调整一些graphics,使其在所有屏幕上看起来都一样。

我在Eclipse上使用Java RCP应用程序工作,但通过JNI使用C或C ++的方式也起作用。 我一直在环顾四周,但找不到任何东西。

也许这个答案从这里可能会帮助你:

[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 = g.GetHdc(); int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES); int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight; return ScreenScalingFactor; // 1.25 = 125% }