zoukankan      html  css  js  c++  java
  • C# winform 双屏显示

     双屏显示1
    // 利用WinForm中的Screen类,即可比较方便地实现多窗体分别在多个屏幕上显示。
            //•获取当前系统连接的屏幕数量: Screen.AllScreens.Count();
            //•获取当前屏幕的名称:string CurrentScreenName = Screen.FromControl(this).DeviceName;
            //•获取当前屏幕对象:Screen CurrentScreen = Screen.FromControl(this);
            //•获取当前鼠标所在的屏幕:Screen CurrentScreen = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y));
            //•让窗体在第2个屏幕上显示:
            //this.Left = ((Screen.AllScreens[1].Bounds.Width - this.Width) / 2);
            //this.Top = ((Screen.AllScreens[1].Bounds.Height - this.Height) / 2);
            private void showOnMonitor(int showOnMonitor)
            {
                Screen[] sc;
                sc = Screen.AllScreens;
                if (showOnMonitor >= sc.Length)
                {
                    showOnMonitor = 0;
                }
                this.FormBorderStyle = FormBorderStyle.None; //无边框全屏显示
                this.StartPosition = FormStartPosition.Manual;
                this.Location = new Point(sc[showOnMonitor].Bounds.Left, sc[showOnMonitor].Bounds.Top);  
                //this.Location = new Point(((sc[showOnMonitor].Bounds.Width-this.Width)/2), ((sc[showOnMonitor].Bounds.Height-this.Height)/2));
                // If you intend the form to be maximized, change it to normal then maximized.               
                //this.WindowState = FormWindowState.Normal;
                this.WindowState = FormWindowState.Maximized;//最大化窗口
    
            }
    
    如果接双显卡时showOnMonitor 参数等于0为主屏,1为扩展屏
     双屏显示2
     1  private void showOnMonitor2()
     2         {
     3             Screen[] sc;
     4             sc = Screen.AllScreens;
     5             //get all the screen width and heights 
     6             Form1 f = new Form1();
     7             f.FormBorderStyle = FormBorderStyle.None;
     8             f.Left = sc[1].Bounds.Width;
     9             f.Top = sc[1].Bounds.Height;
    10             f.StartPosition = FormStartPosition.Manual;
    11             f.Location = sc[1].Bounds.Location;
    12             Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
    13             f.Location = p;
    14             f.WindowState = FormWindowState.Maximized;
    15             f.Show();
    16         }
    17 
    18 接入双显卡时sc[0]为主屏、sc[1]扩展屏
    一个窗体双屏显示
      this.Location = new Point(0,0);            
                Screen[] sc;
                sc = Screen.AllScreens;
                this.Width = (sc[0].Bounds.Width + sc[1].Bounds.Width);//+20;
                this.Height = (sc[0].Bounds.Height); //+200;
                this.FormBorderStyle = FormBorderStyle.None; //边框样式
                webBrowser1.Width = sc[0].Bounds.Width;
                webBrowser1.Height = sc[0].Bounds.Height;
                webBrowser1.Location = new Point(sc[0].Bounds.Location.X, sc[0].Bounds.Location.Y);            
                webBrowser1.Url = new Uri("http://www.google.com.hk");
    
    
                webBrowser2.Width = sc[1].Bounds.Width;
                webBrowser2.Height = sc[1].Bounds.Height;
                webBrowser2.Location = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
                webBrowser2.Url = new Uri("http://www.baidu.com");
  • 相关阅读:
    关于使用sudo找不到环境变量的问题
    HDFS修改副本数,并生效。
    Linux创建用户,SFTP只允许访问指定目录
    Docker 技术系列之安装Redis单机版和集群版
    Docker 技术系列之安装多版本Mysql5.6和Mysql5.7
    Docker 技术系列之安装Docker Desktop for Mac
    第五章 Mac系统软件-安装Java Web开发环境基本软件
    第四章 感受Mac之美-效率提高从操作快捷键开始
    第三章 感受Mac之美-万里挑一的装机必备软件
    第二章 感受Mac 之美-惊艳从Mac 外设开始,一周后的使用感受
  • 原文地址:https://www.cnblogs.com/zzcong/p/2547877.html
Copyright © 2011-2022 走看看