问题描述
我有vb.net winform应用程序,该应用程序具有
AutoScaleMode = dpi
AutoScale =假
AutoSize = true
I have vb.net winform app that hasAutoScaleMode = dpiAutoScale = falseAutoSize = true
更改DPI设置后已退出。
我也尝试过重新启动计算机。
I've signed off after changing DPI setting.I also tried restarting the machine.
Using g As Graphics = form.CreateGraphics()
Dim dpiX As Single = g.DpiX
无论DPI设置如何,dpiX始终为96。有人知道我在做什么错吗?
dpiX is always 96 regardless of DPI setting. Anyone know what I am doing wrong?
推荐答案
我找到了解决方案。我的应用清单必须说它是dpiAware。
因为我试图检测到较高的DPI并显示警告消息框,而不是真的没有使我的应用程序dpi知道,所以我无法做到这一点。
您可以从注册表中获得有关dpi的信息:
HKEY_CURRENT_USER\控制面板\桌面
LogPixels。
I found solution. My app's manifest has to say it is dpiAware.Because I am trying to detect high DPI and show a warning message box and not really trying to make my app dpi aware, I couldn't do that.You can get dpi aware information from registry: HKEY_CURRENT_USER\Control Panel\DesktopLogPixels.
如果使用的是默认情况下,您将没有密钥。更改DPI设置将创建一个。
If you are using default, you won't have the key. Changing DPI setting will create one.
这篇关于System.Drawing.Graphics.DpiX始终返回96的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!