【问题标题】:Screen Text size in .NET.NET 中的屏幕文本大小
【发布时间】:2010-05-17 21:05:39
【问题描述】:

有没有办法知道 .NET/C# 中的文本大小是否为 125%?

设置来自控制面板\外观和个性化\显示...

【问题讨论】:

标签: c# .net


【解决方案1】:

我自己没试过。

Windows 7 之前的 Windows 中的此注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI:LogPixels

Windows 7 中的这个:
HKEY_CURRENT_USER\Control Panel\Desktop:LogPixels

全部根据MSDN Forum中的这个帖子

这里有一些额外的资源:
Creating a DPI-Aware Application
C# Scaling UserControl content to match users Dpi/Font Size
About DPI issue

【讨论】:

  • 我可以使用 HKEY_CURRENT_USER\Control Panel\Desktop\LogPixels 获得正确的值。使用 100% 时该值为 96,使用 125% 时该值为 120。谢谢!
【解决方案2】:

我不确定,但也许您可以获取 Dpi 设置并检查它们是否为 96:

using(Graphics g = this.CreateGraphics())
{
    MessageBox.Show(g.DpiX.ToString() + Environment.NewLine + g.DpiY.ToString());
}

不过,您可能需要先致电 SetProcessDPIAware

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多