我怎么知道是什么监控WPF窗口处于 [英] How do I know what monitor a WPF window is in

查看:153
本文介绍了我怎么知道是什么监控WPF窗口处于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#应用程序,我怎么能发现如果一个WPF窗口是在主显示器或另一台显示器?

In a C# application, how can I find out if a WPF window is in the primary monitor or another monitor?

推荐答案

如果最大化了窗口,那么你可以不依赖于window.Left或window.Top可言,因为它们可能是坐标是最大化了。但是你可以在任何情况下做到这一点:

If the window is maximized then you cannot rely on window.Left or window.Top at all since they may be the coordinates before it was maximized. But you can do this in all cases:

    var screen = System.Windows.Forms.Screen.FromHandle(
       new System.Windows.Interop.WindowInteropHelper(window).Handle);

这篇关于我怎么知道是什么监控WPF窗口处于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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