zoukankan      html  css  js  c++  java
  • c# winfrom 子窗体分屏显示

    参考博客:https://blog.csdn.net/kailan818/article/details/8517126

    实现代码:

    private void button1_Click(object sender, EventArgs e)
            {
                var frmChild = Application.OpenForms["frmChild"];
                if (frmChild != null)
                {
                    frmChild.Activate();
                }
                else
                {
                    frmChild frm = new frmChild();
                    frm.Owner = this;//申明当前窗体是子窗体
                    ShowOnMonitor(frm);
                    frm.Show();
                }
            }
    
            private void ShowOnMonitor(frmChild frm)
            {
                Screen[] sc = Screen.AllScreens;
                if (sc.Length > 1)
                {
                    //获取当前屏幕
                    Screen CurrentScreen = Screen.FromControl(this);
                    //获取当前鼠标所在的屏幕
                    //Screen CurrentScreen = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y));
                    var child = sc.Where(it => it.DeviceName != CurrentScreen.DeviceName).FirstOrDefault();
                    frm.StartPosition = FormStartPosition.Manual;
                    frm.Location = new Point(child.Bounds.Left, child.Bounds.Top);
    
                }
                // If you intend the form to be maximized, change it to normal then maximized.  
                frm.WindowState = FormWindowState.Normal;
                frm.WindowState = FormWindowState.Maximized;
            }

    demo地址:https://gitee.com/cainiaoA/winformSplit

  • 相关阅读:
    hadoop hdfs总结 NameNode部分 概述
    最近近况
    hadoop hdfs总结 NameNode部分 1
    rsync 使用
    SmartHost
    hadoop unit test 问题
    git 使用记录
    java 类内存分配计算
    hadoop hdfs总结 NameNode部分 2
    0417 430调试技巧
  • 原文地址:https://www.cnblogs.com/shuaimeng/p/11655001.html
Copyright © 2011-2022 走看看