How to Close/Minimize MDI Child Window in VB

ID Number: Q80913

1.00

WINDOWS

Summary:

The Close event procedure for an MDI Child custom control window is

triggered by using the Control-menu box for the child window

(double-clicking in the upper left box of the child window), but this

does not in turn minimize the form. This is by design and is

documented in the "Microsoft Professional Toolkit for Visual Basic:

Custom Control Reference" in the MDI Child section (see remarks on

"close").

By placing the code described below in the Close event procedure, you

can either hide or minimize the MDI child window.

This information applies to Microsoft Professional Toolkit for

Microsoft Visual Basic programming system version 1.0 for Windows.

More Information:

To hide or minimize an MDI child window, do the following. (Minimizing

the MDI child window will cause the MDI child to be minimized to an

icon within its parent's client area.)

Example

-------

1. Run Visual Basic, or from the File menu, choose New Project (ALT,

F, N) if Visual Basic is already running. Form1 is created by

default.

2. From the File menu, choose Add File. In the Files box, select the

MDICHILD.VBX custom control file. The MDI Child tool will appear in

the Toolbox.

3. Click on the MDI Child tool to select the MDI Child window control.

Click and drag on the form to place a MDI Child window control.

4. Double-click on the MDI child window to open the Code window. In

the Procedure box, select the Close event.

5. Enter one of the following code examples to the MDIChild1_Close

event:

Sub MDIChild1_Close ()

'This will hide the control as if it were closed.

MDIChild1.Visible = 0

End Sub

-or-

Sub MDIChild1_Close ()

'This will minimize the control to an icon.

MDIChild1.WindowState = 1 ' MINIMIZED

End Sub

6. From the Run menu, choose Start to run the application.

7. Double-click in the upper left corner of the child window (the

Control-menu box).

Depending on which code you selected for the Close event, the MDI

child window will become invisible or it will be minimized to an icon.

Additional reference words: 1.00