Visual Basic and Child Windows

Dear Dr. GUI:

I use MDI in Visual Basic 3.0. In the child window, I do not like the user to close any child window, so I set the property "ControlBox=false" in the child window. It works fine if the child window is not maximized. But, after the child window is maximized, the Restore button is gone. There is no way to restore the child window to normal size. Only cascading or tiling the window enables the Restore button. Is there any way to solve the problem?

K-Yang
khuang@scudc.scu.edu

Dr. GUI replies:

Luckily I didn't take an oath to do this job. So, I can offer you two solutions, one of which is very slippery. In the first solution (here comes the slime), you can turn the MaxButton property to FALSE, which prevents the maximization of the window in the first place! No maximization—no problem (groan, groan!). The second solution gets more to the essence of the problem. Set (and keep) the child window's ControlBox property to TRUE, and bypass the child window's unload process by modifying the child window's Form_Unload function as follows:

Sub Form_Unload (Cancel As Integer)
  If Not gEnd Then Cancel = True: WindowState = 1
End Sub

This has the effect of keeping the window around, so when you maximize it, there is a window to restore. It has not been unloaded, and the Restore button is enabled. The other benefit is that you may minimize the window, and suddenly your application begins to look like a multiple-document interface (MDI) application (duh, probably because it is!).