Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Painting issue
Message
General information
Forum:
ASP.NET
Category:
Forms
Title:
Miscellaneous
Thread ID:
00967297
Message ID:
00970416
Views:
26
Even worse behavior i just discovered with this code:

1. Run the form, maximize it.
2. use ALT-TAB to go somewhere else.
3. use ALT-TAB to come back to the form.
4. Try to use the file menu....
5. Try to restore down the form and resize it....

pretty mean behavior....

>Ok,
>
>After some testings, i found what is causing all my forms weird behaviors, it looks like there is a bug when playing with the opacity level of an MDI Parent. Here's the repro code:
>
>
>using System;
>using System.Drawing;
>using System.Collections;
>using System.ComponentModel;
>using System.Windows.Forms;
>using System.Data;
>
>namespace WindowsApplication1
>{
>	/// <summary>
>	/// Summary description for Form1.
>	/// </summary>
>	public class Form1 : System.Windows.Forms.Form
>	{
>		private System.Windows.Forms.MainMenu mainMenu1;
>		private System.Windows.Forms.MenuItem menuItem1;
>		private System.Windows.Forms.MenuItem menuItem2;
>		/// <summary>
>		/// Required designer variable.
>		/// </summary>
>		private System.ComponentModel.Container components = null;
>
>		public Form1()
>		{
>			//
>			// Required for Windows Form Designer support
>			//
>			InitializeComponent();
>                        ///// reset the opacity to 1 here
>                        ///// usually i would use a timer to do so
>                        ///// this line is not really the problem
>                        ///// and can stay here
>			this.Opacity = 1d;
>			//
>			// TODO: Add any constructor code after InitializeComponent call
>			//
>		}
>
>		/// <summary>
>		/// Clean up any resources being used.
>		/// </summary>
>		protected override void Dispose( bool disposing )
>		{
>			if( disposing )
>			{
>				if (components != null)
>				{
>					components.Dispose();
>				}
>			}
>			base.Dispose( disposing );
>		}
>
>		#region Windows Form Designer generated code
>		/// <summary>
>		/// Required method for Designer support - do not modify
>		/// the contents of this method with the code editor.
>		/// </summary>
>		private void InitializeComponent()
>		{
>			this.mainMenu1 = new System.Windows.Forms.MainMenu();
>			this.menuItem1 = new System.Windows.Forms.MenuItem();
>			this.menuItem2 = new System.Windows.Forms.MenuItem();
>			//
>			// mainMenu1
>			//
>			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
>																					  this.menuItem1});
>			//
>			// menuItem1
>			//
>			this.menuItem1.Index = 0;
>			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
>																					  this.menuItem2});
>			this.menuItem1.Text = "File";
>			//
>			// menuItem2
>			//
>			this.menuItem2.Index = 0;
>			this.menuItem2.Text = "Test form";
>			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
>			//
>			// Form1
>			//
>			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
>			this.ClientSize = new System.Drawing.Size(640, 481);
>			this.IsMdiContainer = true;
>			this.Menu = this.mainMenu1;
>			this.Name = "Form1";
>
>///////////Removing this line will fix the problem /////////////////////
>			this.Opacity = 0;
>////////////////////////////////////////////////////////////////////////
>			this.Text = "Form1";
>
>		}
>		#endregion
>
>		/// <summary>
>		/// The main entry point for the application.
>		/// </summary>
>		[STAThread]
>		static void Main()
>		{
>			Application.EnableVisualStyles();
>			Application.DoEvents();
>			Application.Run(new Form1());
>
>		}
>
>		private void menuItem2_Click(object sender, System.EventArgs e)
>		{
>			Form2 frm = new Form2();
>			frm.MdiParent = this;
>			frm.Show();
>		}
>	}
>	public class Form2 : System.Windows.Forms.Form
>	{
>		private System.Windows.Forms.Label label1;
>		private System.Windows.Forms.TextBox textBox1;
>		private System.Windows.Forms.ListBox listBox1;
>		private System.Windows.Forms.TextBox textBox2;
>		private System.Windows.Forms.TextBox textBox3;
>		private System.Windows.Forms.TextBox textBox4;
>		private System.Windows.Forms.TextBox textBox5;
>		private System.Windows.Forms.TextBox textBox6;
>		/// <summary>
>		/// Required designer variable.
>		/// </summary>
>		private System.ComponentModel.Container components = null;
>
>		public Form2()
>		{
>			//
>			// Required for Windows Form Designer support
>			//
>			InitializeComponent();
>
>			//
>			// TODO: Add any constructor code after InitializeComponent call
>			//
>		}
>
>		/// <summary>
>		/// Clean up any resources being used.
>		/// </summary>
>		protected override void Dispose( bool disposing )
>		{
>			if( disposing )
>			{
>				if(components != null)
>				{
>					components.Dispose();
>				}
>			}
>			base.Dispose( disposing );
>		}
>
>		#region Windows Form Designer generated code
>		/// <summary>
>		/// Required method for Designer support - do not modify
>		/// the contents of this method with the code editor.
>		/// </summary>
>		private void InitializeComponent()
>		{
>			this.label1 = new System.Windows.Forms.Label();
>			this.textBox1 = new System.Windows.Forms.TextBox();
>			this.listBox1 = new System.Windows.Forms.ListBox();
>			this.textBox2 = new System.Windows.Forms.TextBox();
>			this.textBox3 = new System.Windows.Forms.TextBox();
>			this.textBox4 = new System.Windows.Forms.TextBox();
>			this.textBox5 = new System.Windows.Forms.TextBox();
>			this.textBox6 = new System.Windows.Forms.TextBox();
>			this.SuspendLayout();
>			//
>			// label1
>			//
>			this.label1.Location = new System.Drawing.Point(8, 16);
>			this.label1.Name = "label1";
>			this.label1.TabIndex = 0;
>			this.label1.Text = "A label";
>			//
>			// textBox1
>			//
>			this.textBox1.Location = new System.Drawing.Point(8, 40);
>			this.textBox1.Name = "textBox1";
>			this.textBox1.TabIndex = 1;
>			this.textBox1.Text = "textBox1";
>			//
>			// listBox1
>			//
>			this.listBox1.Location = new System.Drawing.Point(8, 128);
>			this.listBox1.Name = "listBox1";
>			this.listBox1.Size = new System.Drawing.Size(248, 95);
>			this.listBox1.TabIndex = 2;
>			//
>			// textBox2
>			//
>			this.textBox2.Location = new System.Drawing.Point(120, 40);
>			this.textBox2.Name = "textBox2";
>			this.textBox2.TabIndex = 3;
>			this.textBox2.Text = "textBox2";
>			//
>			// textBox3
>			//
>			this.textBox3.Location = new System.Drawing.Point(8, 64);
>			this.textBox3.Name = "textBox3";
>			this.textBox3.TabIndex = 4;
>			this.textBox3.Text = "textBox3";
>			//
>			// textBox4
>			//
>			this.textBox4.Location = new System.Drawing.Point(120, 64);
>			this.textBox4.Name = "textBox4";
>			this.textBox4.TabIndex = 5;
>			this.textBox4.Text = "textBox4";
>			//
>			// textBox5
>			//
>			this.textBox5.Location = new System.Drawing.Point(8, 88);
>			this.textBox5.Name = "textBox5";
>			this.textBox5.TabIndex = 6;
>			this.textBox5.Text = "textBox5";
>			//
>			// textBox6
>			//
>			this.textBox6.Location = new System.Drawing.Point(120, 88);
>			this.textBox6.Name = "textBox6";
>			this.textBox6.TabIndex = 7;
>			this.textBox6.Text = "textBox6";
>			//
>			// Form2
>			//
>			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
>			this.ClientSize = new System.Drawing.Size(292, 266);
>			this.Controls.Add(this.textBox6);
>			this.Controls.Add(this.textBox5);
>			this.Controls.Add(this.textBox4);
>			this.Controls.Add(this.textBox3);
>			this.Controls.Add(this.textBox2);
>			this.Controls.Add(this.listBox1);
>			this.Controls.Add(this.textBox1);
>			this.Controls.Add(this.label1);
>			this.Name = "Form2";
>			this.Text = "Form2";
>			this.ResumeLayout(false);
>
>		}
>		#endregion
>	}
>}
>
>
>
>
>run the form and go to file-> testForm, see how it flickers when the controls are created, now move the child form around, see how the controls are not moving smootly.
>
>remove the line:
>this.Opacity = 0;
>
>and try again, this fixes the problem, go figure....
>
>I'll never play with this opacity thigny again.
>
>HTH.
Previous
Reply
Map
View

Click here to load this message in the networking platform