如何获取DPI在C#.NETDPI、NET

由网友(感情你情我愿i)分享简介:我尝试建立使用C#.NET Windows窗体应用程序。如何获得DPI在Windows窗体应用程序。 C#?我读过以前有DPIX和DPIY我们可以使用从.NET来获得当前的DPI,不就可以了?感谢所有... I've try to build a windows form application using C# ....

我尝试建立使用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();
}
阅读全文

相关推荐

最新文章