How do I detect if the user's font (DPI) is set to small, large, or something else?

后端 未结 2 676
刺人心
刺人心 2020-12-11 04:41

I need to find out if the user\'s screen is set to normal 96 dpi (small size), large 120 dpi fonts, or something else. How do I do that in VB.NET (preferred) or C#?

2条回答
  •  北海茫月
    2020-12-11 05:20

    Have a look at the DpiX and DpiY properties. For example:

    using (Graphics gfx = form.CreateGraphics())
    {
        userDPI = (int)gfx.DpiX;
    }
    

    In VB:

    Using gfx As Graphics = form.CreateGraphics()
        userDPI = CInt(gfx.DpiX)
    End Using
    

提交回复
热议问题