Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Window application opens two windows when we minimize & maximize application in processing time

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 80
    Comment on it

    How to resolve "window application opens two windows when we minimize & maximize application in processing time"?

     

    Sometime we face an issue in window application that if one window take more processing time to move to the next window for some reason, and in meantime we minimize and then maximize that window then after processing both windows are open at same time. First window is not hide.
    To resolve this issue I add some code in second form on page_load and form_closing event.
    Here below is the given code in which I login from first form and after login I move to second form.

    Form1:

    public partial class Form1 : Form
    {
    	public Form1()
    	{
    		InitializeComponent();
    	}
    	private void btnLogin_Click(object sender, EventArgs e)
    	{
    	     Cursor.Current = Cursors.WaitCursor; // add wait cursor to show that some process is working
    	    //login code 
    	    Cursor.Current = Cursors.Default;    //set cursor to default cursor
    		this.Hide();
    		Form2 form2 = new Form2();
    		form2.form1 = this;
            form2.Show();
    	}
    }

    Form2:

    public partial class Form2 : Form
    {
        public Form1 form1;
    	public Form2()
    	{
    		InitializeComponent();
    	}
    	private void Form2_Load(object sender, EventArgs e)
    	{
    		if (form1 != null)
    		{
    			form1.Visible = false;
    			form1.ShowInTaskbar = false;
    		}
    	}
    	private void Form2_FormClosing(object sender, FormClosingEventArgs e)
    	{
    		if (form1 != null)
    			form1.Close();
    		
    	}
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: