System.Drawing.Graphics.DpiX始终返回96 [英] System.Drawing.Graphics.DpiX always return 96

查看:143
本文介绍了System.Drawing.Graphics.DpiX始终返回96的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有vb.net winform应用程序,该应用程序具有
AutoScaleMode = dpi
AutoScale =假
AutoSize = true

I have vb.net winform app that has AutoScaleMode = dpi AutoScale = false AutoSize = 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\Desktop LogPixels.

如果使用的是默认情况下,您将没有密钥。更改DPI设置将创建一个。

If you are using default, you won't have the key. Changing DPI setting will create one.

这篇关于System.Drawing.Graphics.DpiX始终返回96的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆