MDIForm Object for Visual Basic 6.0 Users
In Visual Basic 6.0, an MDIForm was a special type of form that acted as a container for an MDI (Multiple Document Interface) application. In Visual Basic 2005, any form with itsproperty set to true can act as an MDI container.
Child Forms and Multiple MDI Forms
In Visual Basic 6.0, setting the MDIChild property on a child form identifies it as a child of the MDI form; an MDI application can have only one MDI form.
In Visual Basic 2005, theproperty replaces the MDIChild property and identifies the MDI form that will contain the child form; MDI applications can have multiple MDI containers.
BackColor and Picture Properties
In Visual Basic 6.0, the background color of an MDIForm can be changed by setting the BackColor property, and a background picture can be displayed by setting the Picture property.
In Visual Basic 2005, it is not possible to change the background color or display a picture on an MDI form. Although you can set theand properties on the form, setting the IsMdiContainer property to true invalidates these settings.
In Visual Basic 6.0, the AutoShowChildren property of an MDI form is used to automatically show an MDI child form when it is loaded. Standard forms do not have this behavior; calling the Load method loads but does not show the form.
In Visual Basic 2005, you must explicitly call themethod in order to display an MDI child form.
Controls and Graphics on MDI Forms
In Visual Basic 6.0, it is not possible to add most controls to an MDIForm. You can only add docked controls such as the Menu, StatusBar, or ToolBar control. In addition, graphics methods such as Circle or Line cannot be used on an MDIForm.
In Visual Basic 2005, you can add any control to an MDI form; however the behavior may not be what you would expect. Any controls on a form with the IsMdiContainer property set to true will "float" on top of any MDI child forms. Although you can make calls to graphics methods in theevent, the graphics will not appear at run time.
Code Changes for MDI Forms
The following examples illustrate differences in coding techniques between Visual Basic 6.0 and Visual Basic 2005.
Code Changes for Showing MDI Child Forms
The following code demonstrates how to display five instances of an MDI child form.
' Visual Basic 6.0 Dim F(1 To 4) As New Form1 Private Sub MDIForm_Load() Dim i As Integer Load Form1 For i = 1 To 4 F(i).Caption = "Form" & i + 1 F(i).Show Next I End Sub
Code Changes for Arranging MDI Child Windows
The following code demonstrates how to write code to change the arrangement of windows in an MDI application. It assumes that you have created menu items for each option.
' Visual Basic 6.0 Private Sub menuCascade_Click() Me.Arrange vbCascade End Sub Private Sub menuTileHorizontally_Click() Me.Arrange vbHorizontal End Sub Private Sub menuTileVertically_Click() Me.Arrange vbVertical End Sub
' Visual Basic 2005 Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.Cascade) End Sub
' Visual Basic 2005 Private Sub TileVerticleToolStripMenuItem_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileVertical) End Sub
MDI Form Property and Method Equivalencies
The following table lists Visual Basic 6.0 properties and methods and their Visual Basic 2005 equivalents. Only properties and methods that are unique to the MDIForm object are listed — for other properties, methods, and events see.
MDIForm Properties and Methods
|Visual Basic 6.0||Visual Basic 2005 Equivalent|
New implementation. For more information, see.
New implementation. The background for an MDI form will always be the default (Control).
New implementation. MDI forms in Visual Basic 2005 cannot directly display pictures.
When upgrading a MDI application from Visual Basic 6.0 to Visual Basic 2005, any MDIForm objects are upgraded to regular forms and their IsMdiContainer property is set to true.
In Visual Basic 2005, the AutoShowChildren property no longer exists. To emulate the Visual Basic 6.0 behavior, a line of code is added during upgrade to show each child form if AutoShowChildren is set to true in the original application.