Ejemplo n.º 1
0
        private void MaximizeTPTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (aTabControl.SelectedTab == null)
                {
                    return;
                }
                foreach (Control aForm in aTabControl.SelectedTab.Controls)
                {
                    if (aForm is Form)
                    {
                        this.SuspendLayout();
                        ControlHelper.SuspendDrawing(this);
                        Form form = aForm as Form;
                        form.Dock        = DockStyle.Fill;
                        form.Width       = ((TabPage)form.Parent).ClientSize.Width;
                        form.Height      = ((TabPage)form.Parent).ClientSize.Height;
                        form.WindowState = FormWindowState.Minimized;
                        while (true)
                        {
                            if (form.WindowState != FormWindowState.Maximized)
                            {
                                form.WindowState = FormWindowState.Maximized;
                            }
                            else
                            {
                                break;
                            }
                        }
                        ControlHelper.ResumeDrawing(this);
                        this.ResumeDrawing();
                        this.ResumeLayout();
                        //form.WindowState = FormWindowState.Maximized;
                    }
                }
                //foreach (TabPage atp in aTabControl.TabPages)
                //{
                //    foreach (Control acontrol in atp.Controls)
                //    {
                //        // acontrol.Dock = DockStyle.Fill;
                //        // acontrol.Refresh();
                //        if (acontrol is Form)
                //        {
                //            Form form = acontrol as Form;

                //            form.WindowState = FormWindowState.Normal;
                //            form.Width = ((TabPage)form.Parent).ClientSize.Width;
                //            form.Height = ((TabPage)form.Parent).ClientSize.Height;
                //            while (true)
                //            {
                //                if (form.WindowState != FormWindowState.Maximized)
                //                {
                //                    form.WindowState = FormWindowState.Maximized;
                //                    form.Refresh();
                //                }
                //                else
                //                {
                //                    break;
                //                }
                //            }
                //            //form.WindowState = FormWindowState.Maximized;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + " IN Main2[MaximizeTPTimer_Tick] Exception " + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally { MaximizeTPTimer.Stop(); }
        }