Windows缩放 [英] Windows scaling
问题描述
Windows 8/10已开始包含一个滑块,该滑块可缩放GUI元素的大小,右键单击桌面->显示.对于拥有4k笔记本电脑屏幕的同事来说是250%,而在4k 28英寸屏幕上使用相同分辨率的同事是150%.
Windows 8/10 has started to include a slider for how much GUI elements should scale, right click on desktop -> display. For a colleague with a laptop 4k-screen it's 250% while another colleague using the same resolution on a 4k 28" screen it's 150%.
我如何以编程方式读取该值?我需要调整一些图形,使其在所有屏幕上看起来都一样.
How do I read that value programmatically? I need to adjust some graphics so it looks the same on all screens.
我正在Eclipse RCP应用程序上使用Java进行工作,但是通过JNI使用C或C ++的方法也可以使用.我一直在环顾四周,但找不到任何东西.
I'm working in Java on a Eclipse RCP application, but a way that uses C or C++ through JNI works too. I've been looking around but can't find anything.
推荐答案
也许是答案,来自
Maybe this answer from here might help you:
[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%
}
这篇关于Windows缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!