1

Does anyone know if I can check this parameter anywhere?

Mat
  • 202,337
  • 40
  • 393
  • 406
sushiBite
  • 341
  • 2
  • 5
  • 16

2 Answers2

2

You can read Graphics.DpiX to discern this.

Multiply Graphics.DpiX by 100 and divide by 96 and you will have the percentage font scaling. This is true because 100% font scaling equates to 96dpi.

Be warned that if your application is not marked as DPI aware then when the user sets font scaling to 150% the DpiX property will report 96. Off the top of my head I do not know whether or not standard WinForms apps are marked as DPI aware.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
0

If you're not using C#, you need to do two steps to make this work in Windows 7.

First, make your application DPI-aware. This blog explains how to do that. It involves either modifying your application manifest, or calling the SetProcessDPIAware() function (which may or may not exist).

Next, get the X/Y DPI values with GetDeviceCaps(hdc, LOGPIXELSX) and GetDeviceCaps(hdc, LOGPIXELSY), respectively, as explained in this MSDN article.

I have an application that wasn't previously DPI aware, but still broke when used with text scaling (as available in the Windows 7 "Display" control panel), and this got it working, while having no effect on Windows 8 or newer.

ulatekh
  • 1,311
  • 1
  • 14
  • 19