c# winform 多屏显示_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > c# winform 多屏显示

c# winform 多屏显示

 2017/12/8 18:47:50  泽少军  程序员俱乐部  我要评论(0)
  • 摘要:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Configuration;namespaceWinClient{publicpartialclassMainForm:Form
  • 标签:C# for winform

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace WinClient
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                //设置窗体无边框
                this.FormBorderStyle = FormBorderStyle.None;
                //窗口置顶
                this.TopMost = true;
                //开始位置由 Location 决定
                this.StartPosition = FormStartPosition.Manual;

                Screen[] screens = System.Windows.Forms.Screen.AllScreens;
                if (screens.Length >= 2)
                {
                    //获取扩展屏
                    Screen childerScreen = screens[1];
                    //设置宽高
                    this.Width = childerScreen.Bounds.Width;
                    this.Height = childerScreen.Bounds.Height;
                    //设置显示位置
                    this.Location = childerScreen.WorkingArea.Location;
                }
                else
                {
                    MessageBox.Show("只有一个显示器");
                }
            }
            catch (Exception ex)
            {
                //错误日志处理
            }
        }
    }
}

完整代码下载地址

发表评论
用户名: 匿名