如何获取DPI在C#.NET [英] How To Get DPI in C# .NET

查看:269
本文介绍了如何获取DPI在C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试建立使用C#.NET Windows窗体应用程序。如何获得DPI在Windows窗体应用程序。 C#?我读过以前有DPIX和DPIY我们可以使用从.NET来获得当前的DPI,不就可以了?感谢所有...

I've try to build a windows form application using C# .NET. How to get DPI in Windows Form App. C#? I've read before there is DPIX and DPIY we can use from .NET to get the current DPI, can't it? thanks all...

推荐答案

使用了图形类的一个实例。您可以使用下面的表单中得到这个(可能是在形式上的加载事件处理程序):

Use an instance of the Graphics class. You get this using the following within your form (could be in form's Load event handler):

float dx, dy;

Graphics g = this.CreateGraphics();
try
{
    dx = g.DpiX;
    dy = g.DpiY;
}
finally
{
    g.Dispose();
}

这篇关于如何获取DPI在C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆