4

Is there a way to know if the text size is at 125% from .NET/C#?

The setting comes from Control Panel\Appearance and Personalization\Display ...

BeardinaSuit
  • 889
  • 7
  • 21
  • Do you want to know text size or DPI? (http://blogs.msdn.com/oldnewthing/archive/2004/07/14/182971.aspx) If you do need to know text size, do you just need to know if it's 125%, or what the actual size is? – ICR May 17 '10 at 13:14

2 Answers2

3

I haven´t tried this my self.

This registry key in windows pre Windows 7:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI:LogPixels

And this one in Windows 7:
HKEY_CURRENT_USER\Control Panel\Desktop:LogPixels

All according to this thread in MSDN Forum

Here is some additional resources:
Creating a DPI-Aware Application
C# Scaling UserControl content to match users Dpi/Font Size
About DPI issue

Community
  • 1
  • 1
Jens Granlund
  • 4,950
  • 1
  • 31
  • 31
  • I was abl to get the correct value using HKEY_CURRENT_USER\Control Panel\Desktop\LogPixels. The value is 96 when using 100% and 120 when using 125%. Thanks! – BeardinaSuit May 23 '10 at 14:46
0

I'm not sure but maybe you can just get the Dpi settings and check if they're 96 or not:

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

You might have to call SetProcessDPIAware first though.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116