开发者

Need to find you if the user is using magnified font size 125% or 150% in win 7

开发者 https://www.devze.com 2023-04-03 08:32 出处:网络
Does anyone know if I can check this param开发者_如何学编程eter anywhere?You can read Graphics.DpiX to discern this.

Does anyone know if I can check this param开发者_如何学编程eter anywhere?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消