May 15, 1995
There may be situations in which you do not want a multiple-document interface (MDI) child form displayed while your program is executing. This article explains how you can hide an MDI child form.
A multiple-document interface (MDI) child form allows you to have several windows open at the same time with different documents loaded in each window. This is how Notepad and similar programs operate so that you can switch between different text files. You cannot, however, hide an MDI child form at run time.
So how can you temporarily hide an MDI child window from the user? By moving the window to a nonexistent position on your screen.
In the example program below, the MDI child form is moved off the current viewing area of the screen. Windows® itself doesn't care where you place the window; and, to your user, it appears as if the window has been hidden.
This program shows how you can temporarily hide an MDI child form in your Visual Basic® application. Run the program by pressing the F5 function key. The MDI child window is visible on the screen. Click the mouse on the main form. The MDI child window disappears from view. Double-click the main form and the MDI child form is again visible on the screen.
BorderStyle = 1-Fixed Single
Height = 1140
Left = 2220
Top = 3030
Width = 4605
Private Sub MDIForm_Click()
Form1.Move -(2 * Form1.Width), -(2 * Form1.Height)
End Sub
Private Sub MDIForm_DblClick()
Form1.Move 2220, 3030, 4605, 1140
End Sub
Private Sub
MDIForm_Load()
Form1.Show
Form2.Show
End Sub
Knowledge Base Q115781. "How to Create Hidden MDI Child Forms."