Export (0) Print
Expand All
Expand Minimize
10 out of 15 rated this helpful - Rate this topic

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 its IsMdiContainer property set to true can act as an MDI container.

Conceptual Differences

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, the MdiParent property 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 the BackColor and BackgroundImage properties on the form, setting the IsMdiContainer property to true invalidates these settings.

AutoShowChildren Property

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 the Show method 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 the Paint event, 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
' Visual Basic 2005
Private Sub MDIForm1_Load(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
  Dim i As Integer = 0
  For i = 0 To 4
      Dim F As New FormChild
      F.Text = "Form " & CStr(i + 1)
      F.Show()
  Next
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

' Visual Basic 2005
Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click

  Me.LayoutMdi(MdiLayout.TileHorizontal)
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 Form Object for Visual Basic 6.0 Users.

MDIForm Properties and Methods

Visual Basic 6.0 Visual Basic 2005 Equivalent

ActiveForm property

ActiveMdiChild

Arrange method

LayoutMdi

AutoShowChildren property

New implementation. For more information, see MDI form Show behavior has changed.

BackColor property

New implementation. The background for an MDI form will always be the default (Control).

Picture property

New implementation. MDI forms in Visual Basic 2005 cannot directly display pictures.

Upgrade Notes

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.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.