locked
MDI Child title is visible in maximizing state RRS feed

  • Question

  • Hi,
    I have a project with C#. this is an MDI application. the application
    contains a parent form, several child windows and some message boxes.
    My problem is the following,
    1. If I maximize a Mdi child the title bar of the child window does
    not embed to its parent. rather its visible.
    2. None of the Mdi child windows title bar color get focused color ( I
    mean "blue" ). they are always gray. whether its maximized, minimized,
    selected, brought to front. all I see the gray color.
    3. I have a menu item named "Window" which contains the list of opened
    window.  I mean its the MdiWindowListItem. It never shows the current
    opened windows list.
    4. When I click a menu item, In the click event implementing method, I
    tried to access ActiveMdiChild property. its null. which means, I have
    a activated child window but ActiveMdiChild is not getting that
    window.
    please resolve the problem.
    Wednesday, March 28, 2007 8:35 AM

Answers

  • I solved the problem.
    I did not set the MainMenuStrip of the parent window. After setting everything works fine.
    Now to summerize the resolutions, I followed these steps,

    1)   All childs WindowState was Maximized. I set it to Normal
    2)   Show() method was not called rather Focus() was called for every child. I add the  Show() method
    3)   The Big One:   Parent windows MainMenuStrip property was not set. I set it to indicate the main menu.

    Thanks for helping me to find out the problem.

    Thursday, March 29, 2007 2:27 PM

All replies

  • Are you setting the MdiParent property for all of your child forms? Is the Parent for set to IsMdiContainer = True?


    Wednesday, March 28, 2007 4:50 PM
  • My MDIParent object has isMdiContainer property set to true;
    and all the MdiChilds' MdiParent property is set to MdiParent. most of the time the general statement is,


    obj.MdiParent = this;

    here this is the top level window, ie, MdiParent.

    Wednesday, March 28, 2007 9:50 PM
  • Sounds like you're setting the child's TopLevel property to false.  Don't.
    Wednesday, March 28, 2007 11:38 PM
  • one of my problem is solved.
    the problem was,

    3. I have a menu item named "Window" which contains the list of opened window.  I mean its the MdiWindowListItem. It never shows the current opened windows list.

    To resolve this problem, I set the WindowState Property of the child to Normal. But others are not resolving. By the way, I tried your [nobugs] suggestion with the combination of TopLevel Property of both child and parent. by using this message box             MessageBox.Show(String.Format("{0}.TopLevel={1}\n{2}.TopLevel={3}",                 this.Name, this.TopLevel, sCtg.Name, sCtg.TopLevel), "Trace TopLevel"); the result is,
    Parent.TopLevel Child.TopLevel Comment/Error
    True True Runtime warning: TopLevel style of a parented control can not be changed.
    parameter name : value.
    Child.TopLevel is set to false.
    True False Default Behaviour. values are not changed
    False True Runtime warning: MDI container forms must be top-level.
    Parameter name: value
    Parent.TopLevel is set to True and Child.TopLevel is set to false
    False False Runtime warning: MDI container forms must be top-level.
    Parameter name: value
    Parent.TopLevel is set to True and Child.TopLevel is set to false
    Now what should I do? Please help.
    Thursday, March 29, 2007 9:54 AM
  • Please ignore my post.  Setting the MDIParent property of a child form automatically sets the TopLevel property to false.  You are setting the MDIParent property, right?
    Thursday, March 29, 2007 10:26 AM
  • Yes of course.

    Thursday, March 29, 2007 10:30 AM
  • Let me show you a code fragment
        public partial class MainApp : Form
        {
            public StockStatus ss;
            public MainApp()
            {
                try
                {
                    ss = new StockStatus();
                    ss.MdiParent = this;
                }
                catch (Exception ex)
                {
                    Integrator.showErrorMessage(ex);
                    return;
                }
            }
       }
    
    Thursday, March 29, 2007 10:39 AM
  • Something is obviously messed up in the MDI plumbing of your app.  Your child forms behave like a TopLevel = false window but not an MDI child.  Next guess: who is calling Show()?  Is it another thread?
    Thursday, March 29, 2007 11:11 AM
  • Wow,
    No one was calling show() !
    I added a show() calling. Problem 1 and 2 is now resolved. But a new problem discovered.
    If I maximize the child window its sys menu (minimize,maximize,close) and the icon appears at the top of the MainMenuStrip of the parent window. So I get 2 strip. one for this childs sysmenu and bellow it the Main menu. but It should be in a same strip. and should have Icon first, then menu items of the parent window, then at the corner the sys menu of the child.
    How can I make them togather ?
    The event handler when I click the menuItem.

    private void showStockToolStripMenuItem_Click(object sender, EventArgs e)
            {
                ss.MdiParent = this; // to ensure that the MdiParent is not changed
                ss.showResultSet(); // this function is calling the Show() method
                ss.BringToFront();
            }

    implemention of showResultSet() is

    public virtual void showResultSet(int page, int entryPerPage)
            {
                try
                {
                    RowCount = int.Parse(Global.getDataTable(CountQuery + " limit 1").Rows[0][0].ToString());
                }
                catch (IndexOutOfRangeException)
                {
                    RowCount = 0;
                }
                TotalPage.Text = String.Format("{0}", Math.Ceiling(((double)(RowCount) / (double)entryPerPage)));
                EntriesPerPage = entryPerPage;
                CurrentPage.Text = String.Format("{0}", page);
                PageSize.Text = String.Format("{0}", entryPerPage);
                EntryList.DataSource = Global.getDataTable(String.Format("{0} limit {1},{2}", Query, (page - 1) * entryPerPage, entryPerPage));
                if (!Focused)
                {
                    Focus();
                }
                this.Show();

            }
    Thursday, March 29, 2007 2:12 PM
  • That's by design, any MDI application works that way.  You can't change it.
    Thursday, March 29, 2007 2:16 PM
  • I solved the problem.
    I did not set the MainMenuStrip of the parent window. After setting everything works fine.
    Now to summerize the resolutions, I followed these steps,

    1)   All childs WindowState was Maximized. I set it to Normal
    2)   Show() method was not called rather Focus() was called for every child. I add the  Show() method
    3)   The Big One:   Parent windows MainMenuStrip property was not set. I set it to indicate the main menu.

    Thanks for helping me to find out the problem.

    Thursday, March 29, 2007 2:27 PM