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


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

        //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);
                    }
                } 
            }



  • 相关阅读:
    转:qcow2、raw、vmdk等镜像格式
    openstack配置xen
    透过 Linux 内核看无锁编程
    转:查看进程所消耗的内存
    Ubuntu安装内核源码
    How to mark volume groups as active or inactive
    Failed to access IIS metabase(IIS Exception Problem)
    Android电子书下载:Google Android SDK开发范例大全(第2版)pdf+源码
    几个C++单元测试框架
    JavaScript命名空间namespace的实现方法
  • 原文地址:https://www.cnblogs.com/scottckt/p/872871.html
Copyright © 2020-2023  润新知