BUG: WindowList Menu Does Not Always Show MDIChild Forms

ID: Q247359


The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0


SYMPTOMS

When you open an MDIChild Form, it does not show in the WindowList. This occurs if you have a MDIChild form that is hidden, and the Windowstate of the MDIChild forms is Maximized.


RESOLUTION

Since this problem only occurs when closing maximized MDIChild forms, you need to set the form's Windowstate property to Normal for each MDIChild form before it is closed. This can be done in the MDIChild form's Unload event by setting its Visible property to False. Doing this sets the Windowstate of the form to Normal, while preserving the Windowstate of the MDIChild windows. This method is better than explicitly setting the Windowstate, because doing so also changes the WindowState of the other MDIChild Forms. Please refer to the sample code in the "More Information" section for a workaround.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION


Steps to Reproduce Behavior

  1. Open a new Standard EXE project in Visual Basic. Form1 is created by default


  2. From the Project menu add two more forms to the project (Form2 and Form3).


  3. Set the MDIChild property to True and the WindowState property to Maximized for Form1, Form2 and Form3.


  4. From the Project menu add an MDI Form to the project.


  5. Choose Menu Editor from the Tools menu in the Visual Basic IDE. Add a top level menu to the MDI Form. Give it the following property settings:
    Caption   Open
    Name      mnuMaster
    Index      0


  6. Under this top level menu, create two submenus. Give the first submenu the following property settings:
    Caption   Form1
    Name      mnuOpen
    Index      0
    Give the second submenu the properties:
    Caption   Form2
    Name      mnuOpen
    Index      1


  7. Add another top level menu, giving it the following properties:
    Caption         Window
    Name            mnuMaster
    Index            1
    WindowList    Checked
    At this point you should have a menu that looks like the following:

    Open
    ...Form1
    ...Form2
    Window


  8. Paste the following code into the General Declarations section of the MDI form's code window.

    
    Private Sub MDIForm_Load()
        Load Form1
        Load Form2
        Load Form3
        Form3.Hide
    End Sub
    
    Private Sub mnuOpen_Click(Index As Integer)
        Select Case Index
            Case 0
                Form1.Show
            Case 1
                Form2.Show
        End Select
    End Sub 


  9. Run the Application. See Form1 and Form2 in the Windowlist, and Form2 will be the active window. Now close Form2.


  10. From the Open menu, select Form2. Form2 opens, but notice it is not showing in the Windowlist. Only Form1 shows in the WindowList.


  11. To work around the problem, add the following code to the form Unload event for each MDIChild Form. In our example, do this for Form1, Form2, and Form3.
    
    Me.Visible = False 



REFERENCES

For more information on creating menus, see the "Menu Basics" section in the MSDN.

Additional query words:

Keywords : kbMDI kbMenu kbVBp kbVBp400bug kbVBp500bug kbVBp600bug kbGrpVB kbDSupport
Version : WINDOWS:4.0,5.0,6.0
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: January 10, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.