Question

Does anyone know if I can check this parameter anywhere?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top