Make One Form Parent of Another

Make One Form Parent of Another

Prior to VB5, when you wanted to make a form appear on top of another form, you either made it modal or used an MDIForm with children. If you wanted to go beyond that, you had to use API calls. Starting with VB5, you can use the Show method’s optional ownerform parameter to set one form as the parent of another. This means you always place the child form-not an MDI child-on top of the parent form, even though the parent form remains active. You can also use the style vbModal parameter to force modality, but that defeats any reason to use ownerform. Here’s how you invoke the ownerform parameter, making a form a nonmodal child of a non-MDIForm:

 Private Sub Command1_Click()	Form2.Show , MeEnd Sub


Share the Post: