码迷,mamicode.com
首页 > Windows程序 > 详细

C#写的几段WinForm MDI窗体控制的代码分享

时间:2015-07-19 23:36:14      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:

  

        /// <summary>
        /// 功能:MDI程序中设置主窗体大小为显示器工作区大小
        /// </summary>
        /// <param name="MainForm">主窗体实例</param>
        public static void SetMainFormSize(Form MainForm)
        {
            MainForm.Location = new Point(0, 0);
            MainForm.Width = Screen.PrimaryScreen.WorkingArea.Width;
            MainForm.Height = Screen.PrimaryScreen.WorkingArea.Height;
        }

   *****************************************************

        /// <summary>
        /// 功能:MDI程序中设置子窗体大小为父窗体工作区大小
        /// </summary>
        /// <param name="MdiForm">子窗体实例</param>
        public static void SetMdiChildSize(Form MdiForm)
        {
            MdiForm.Location = new Point(0, 0);
            MdiForm.Width = MdiForm.Parent.ClientSize.Width;
            MdiForm.Height = MdiForm.Parent.ClientSize.Height;
        }

   *****************************************************   

        /// <summary>
        /// 功能:关闭所有打开的MDI子窗体
        /// </summary>
        /// <param name="MainForm">参数:父窗体</param>
        public static void CloseAllMdiForms(Form MainForm)
        {
            if (MainForm.MdiChildren.Length <= 0)
            {
                return;
            }
            else
            {
                foreach (Form SubForm in MainForm.MdiChildren)
                {
                    SubForm.Close();
                }
            }
        }

   *****************************************************   

        /// <summary>
        /// 功能:检测Mdi子窗体状态变化,当子窗体最小化或最大化时恢复默认状态
        /// </summary>
        /// <param name="MdiForm">子窗体实例</param>
        public static void SetMdiFormState(Form MdiForm)
        {
            if (MdiForm == null)
            {
                return;
            }
            else if ((MdiForm.WindowState == FormWindowState.Minimized) || (MdiForm.WindowState==FormWindowState.Maximized))
            {
                MdiForm.WindowState = FormWindowState.Normal;
            }
        }

 

C#写的几段WinForm MDI窗体控制的代码分享

标签:

原文地址:http://www.cnblogs.com/handsome1008/p/4660029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!