本文介绍了有没有一种方法可以调用“识别监视器"来识别用户.从C#函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可以全屏运行的WPF小应用程序,我希望为用户提供选择显示哪个监视器的功能.为了更容易识别列表中的每个监视器,我想做一些类似Windows Display Settings对话框的"Identify Monitors"按钮.

I'm working on a little WPF app that will run fullscreen and I'd like to give the user the ability to choose which monitor it will display on. To make it easier to identify each monitor in the list, I would like to do something like the Windows Display Settings dialog's "Identify Monitors" button.

是否可以使用P/Invoke或其他方法来调用该函数?如果不是这样,我总是可以在每个包含数字的监视器上打开一个新的WPF窗口,但是如果它是内置的,我不想重新发明轮子.

Is there a way to invoke that function using P/Invoke or something? If not, I can always just open a new WPF window on each monitor containing a number, but I don't want to reinvent the wheel if it's built-in somehow.

推荐答案

存在此问题--但它要求确定应用程序在哪个屏幕上运行,如前所述它不会做你想要的.但是,System.Windows.Forms.Screen类可能会提供您需要的方法.

There's this question - In a C# winform how do identify what monitor the app is displayed on - but it asks to identify which screen the application is running on, so as stated it won't do what you want. However, the System.Windows.Forms.Screen class might provide the methods you need.

它具有一个数组:

Sreeen[] AllScreens;

环绕数组,并在由BoundsWorkingArea定义的矩形的中心绘制数组的索引.

Loop over the array and draw the index of the array at the centre of rectangle defined by Bounds or WorkingArea.

这篇关于有没有一种方法可以调用“识别监视器"来识别用户.从C#函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!