【发布时间】:2010-05-17 21:05:39
【问题描述】:
有没有办法知道 .NET/C# 中的文本大小是否为 125%?
设置来自控制面板\外观和个性化\显示...
【问题讨论】:
-
您想知道文字大小还是 DPI? (blogs.msdn.com/oldnewthing/archive/2004/07/14/182971.aspx) 如果您确实需要知道文本大小,您只需要知道它是 125%,还是实际大小是多少?
有没有办法知道 .NET/C# 中的文本大小是否为 125%?
设置来自控制面板\外观和个性化\显示...
【问题讨论】:
我自己没试过。
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
【讨论】:
我不确定,但也许您可以获取 Dpi 设置并检查它们是否为 96:
using(Graphics g = this.CreateGraphics())
{
MessageBox.Show(g.DpiX.ToString() + Environment.NewLine + g.DpiY.ToString());
}
不过,您可能需要先致电 SetProcessDPIAware。
【讨论】: