如何获得多显示器位置? [英] How to get Multi-Monitor Position?

查看:121
本文介绍了如何获得多显示器位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何获取显示器尺寸,虚拟显示器尺寸,
但是我如何获取第二个显示器相对于
的位置 原始的吗?
在桌面上,当我进入显示器的属性设置时,我
可以在显示器周围移动,所以如果说第二个显示器较低
比第一个我可以相应地定位它.有什么方法可以获取这些状态值?
例如,我想知道辅助显示器是否在上面,
在主显示器的下方,右侧还是左侧?说是否要
右边但没有完美对齐我想知道什么是Y坐标

I know how to get the monitor dimensions, virtual monitor dimensions,
but how do I get the location of the second monitor in relationship to
the original?
On the desktop when I go into my property settings for the monitor I
can move around the monitors so if say the second monitor is lower
than the first I can position it accordingly. Is there some way to get those status values?
For instance I''d like to know if the secondary monitor is above,
below, to the right, or left of the primary monitor? Say if it''s to
the right and not aligned perfectly I''d like to know what Y coordinate
it starts/ends at compared to the primary monitor.

推荐答案

查看
Check out Screen Class[^]

If you run this code:
foreach (Screen screen in Screen.AllScreens)
{
  Console.WriteLine("Device Name: " + screen.DeviceName);
  Console.WriteLine("Bounds: " +
      screen.Bounds.ToString());
  Console.WriteLine("Type: " +
      screen.GetType().ToString());
  Console.WriteLine("Working Area: " +
      screen.WorkingArea.ToString());
  Console.WriteLine("Primary Screen: " +
      screen.Primary.ToString());
}



然后对于我的计算机,它返回:



Then for my computer it returns:

Device Name: \\.\DISPLAY1
Bounds: {X=0,Y=0,Width=1920,Height=1080}
Type: System.Windows.Forms.Screen
Working Area: {X=0,Y=0,Width=1920,Height=1050}
Primary Screen: True

Device Name: \\.\DISPLAY2
Bounds: {X=1920,Y=0,Width=1920,Height=1080}
Type: System.Windows.Forms.Screen
Working Area: {X=1920,Y=0,Width=1920,Height=1080}
Primary Screen: False



如果查看工作区,您会看到X和Y不同.
而且您可以看到它在主监视器的上方,下方,右侧或左侧.

我的主要监视器是\\.\ DISPLAY1,右边是辅助监视器.



If you look at Working Area, you can see the X and Y is different.
And there you can see it monitor is above, below, to the right, or left of the primary monitor.

My primary monitor is \\.\DISPLAY1 and to my right I have the secondary monitor.


您可以这样尝试,

Your try like this,

Screen[] sc;
           sc = Screen.AllScreens;
           //get all the screen width and heights
           if (sc.Length > 1)
           {
               customerdisplay.FormBorderStyle = FormBorderStyle.None;
               customerdisplay.Left = sc[1].Bounds.Width;
               customerdisplay.Top = sc[1].Bounds.Height;
               customerdisplay.StartPosition = FormStartPosition.Manual;
               customerdisplay.Location = sc[1].Bounds.Location;
               Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
               customerdisplay.Location = p;
               customerdisplay.WindowState = FormWindowState.Maximized;
               customerdisplay.Show();
           }


客户显示是您要在辅助监视器中显示的表单.

希望对您有所帮助,
Theingi Win


customerdisplay is the form which you want to show in secondary monitor.

Hope be helpful,
Theingi Win


我认为您在询问显示器的分辨率是否正确,然后可以借助Java脚本来解决.
i think you are asking about the resolution of monitor if i am right then you can do it by the help of Java script.


这篇关于如何获得多显示器位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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