有没有办法调用“识别监视器”来自 C# 的函数?
我正在开发一个可以全屏运行的小型 WPF 应用程序,我想让用户能够选择它将在哪个显示器上显示。为了更轻松地识别列表中的每个监视器,我想做一些类似 Windows 显示设置对话框的“识别监视器”按钮的操作。
有没有办法使用 P/Invoke 或其他东西来调用该函数?如果没有,我总是可以在每个显示器上打开一个包含数字的新 WPF 窗口,但如果它以某种方式内置,我不想重新发明轮子。
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有这个问题 - 在C# winform 如何识别应用程序显示在哪个监视器上 - 但它要求识别应用程序正在哪个屏幕上运行,因此如上所述,它不会执行您想要的操作。但是,
System.Windows.Forms.Screen
类可能提供您需要的方法。它有一个数组:
循环数组并在由
Bounds
或WorkingArea
定义的矩形中心绘制数组的索引。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.It has an array:
Loop over the array and draw the index of the array at the centre of rectangle defined by
Bounds
orWorkingArea
.