zoukankan      html  css  js  c++  java
  • 設置當子窗體的的大小小於主窗體時,自動調整大小

    設置當子窗體的的大小小於主窗體時,自動調整大小

        //soctt 20070827 窗體大小改變事件
        this.SizeChanged += new EventHandler(FMzMain_SizeChanged);

           
    /// <summary>
            
    /// soctt 200070827
            
    /// 使子窗體自動調整
           
    /// </summary>
           
    /// <param name="sender"></param>
           
    /// <param name="e"></param>
            void FMzMain_SizeChanged(object sender, EventArgs e)
            {      
                
    //判斷是否有子窗體及窗體狀態變成正常
                if (this.MdiChildren.Length > 0 && this.WindowState== FormWindowState.Normal)
                {
                    
    //定議窗體數量的變量
                    int iCurrMdiNumber = 1;
                    
    //設置窗體的初始位置
                    Point ptLocation = new Point(00);
                    
    foreach (Form fmChild in this.MdiChildren)
                    {
                        
    //判斷是否是活動子窗體
                        if (fmChild == this.ActiveMdiChild)                   
                        {
                            
    //當為活動窗體時,位置為(0,0)
                            ptLocation = new Point(00);
                            
    //fmChild.Location = this.CenterToParent;
                        }
                        
    else
                        {
                            
    //變更子窗體的位置
                            ptLocation.X = iCurrMdiNumber*25;
                            ptLocation.Y
    = iCurrMdiNumber*25;
                        }
                        
    //判斷窗體的寬度是否小於主窗體
                        
    //ClientSize:取得表單工作區大小
                        if (fmChild.Size.Width >= this.ClientSize.Width-10 && fmChild.Size.Height <=this.ClientSize.Height- 80)
                        {    
                            
    //設置窗體的位置
                            fmChild.Location = ptLocation;   
                            
    //變更窗體的大小                
                            fmChild.Size = new Size(this.ClientSize.Width - 10, fmChild.Size.Height);
                            
    //變更變量,用於改變窗體位置
                            iCurrMdiNumber++;      
                        }
                        
    //判斷窗體的高度是否小於主窗體的高度
                        if (fmChild.Size.Height >= this.ClientSize.Height - 80 && fmChild.Size.Width <= this.ClientSize.Width - 10)
                        {                            
                            fmChild.Location 
    = ptLocation;
                            fmChild.Size 
    = new Size(fmChild.Size.Width, this.ClientSize.Height - 80);
                            iCurrMdiNumber
    ++;                       
                        }
                        
    //判斷窗體的高度,寬度是否都小於主窗體
                        if (fmChild.Size.Width >= this.ClientSize.Width - 10 && fmChild.Size.Height >= this.ClientSize.Height - 80)
                        {                       
                            fmChild.Location 
    = ptLocation;
                            fmChild.Size 
    = new Size(this.ClientSize.Width - 10this.ClientSize.Height - 80);
                            
    //fmChild.Size = new Size(this.Size.Width - 30, fmChild.Size.Height - 125);
                            iCurrMdiNumber++;           
                        }
                        
    //設置子窗體最小大小
                        fmChild.MinimumSize = new Size(550400);
                    }
                } 
            }



  • 相关阅读:
    string_view暴力串串题
    字符串hash暴力串串题
    C++刷leetcode几点注意事项
    微软面试算法题(整理)
    Leetcode中的Dijkstra算法
    gdb在线调试多线程程序
    2022亚马逊校园招聘软件开发实习提前批面试题
    python模块tqdm(进度条)的使用
    解决 Failed while installing Dynamic Web Module
    最新eclipse从零开始建立SpringMVC项目(详细过程)
  • 原文地址:https://www.cnblogs.com/scottckt/p/872871.html
Copyright © 2011-2022 走看看