Results 1 to 2 of 2

Thread: Active Mdi Child Question[RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188

    Active Mdi Child Question[RESOLVED]

    I am writting a mdi application which contains multiple types of child windows and I am trying to keep track of what the next active window of a certain type is. I'm not sure how to explain this so try this.

    2 window types of child forms: Visual and Custom

    I have a variable for activeStatic which is the Visual child closest to the top of the active form stack

    Say I closed a Visual child and I wanted to get the next one in the active form stack but the next window to get active in the application would be a Custom form.

    Problem simply this.ActiveMdiChild would return the next window but it will not always be a Visual form and I do not want to close it to get to the next form I'm looking for.

    Without having to code some huge collection/array to keep track of the order does anyone know a way of fixing my problem?
    Last edited by Tewl; Nov 15th, 2003 at 08:01 PM.

  2. #2
    Lively Member
    Join Date
    Dec 1999
    Posts
    106
    In the MDI container form add the following code
    Code:
    		
    public void windowClosed(Form closingForm)
    {
    	// get the child forms
    	Form[] children = this.MdiChildren;
    	// work back thro the stack of forms 
    	for(int i=children.Length -1; i>-1; i--)
    	{
    		Form child = children[i];
    		// if this child is not the closing form
    		if (! child.Equals(closingForm))
    		{
    			// if the next child is the same type as the closing form then bring it up to top
    			if (child.GetType().Equals(closingForm.GetType()))
    			{
    				child.BringToFront();
    				break;
    			}
    		}
    	}
    }
    In each if the child forms add the following code to the Closed event
    Code:
    private void FormXXX_Closed(object sender, System.EventArgs e)
    {
    	((FormContainer)this.ParentForm).windowClosed(this);		
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width