|
|
Title | Make a form that contains other forms in a PictureBox |
Description | This example shows how to make a form that contains other forms in a PictureBox in Visual Basic 6. It uses SetPicture to reparent the sub form. |
Keywords | Form, subform, SetParent |
Categories | Controls |
|
|
The program uses SetParent to put new forms inside the PictureBox. When the main form unloads, the program unloads its subforms.
|
|
Private Sub Command1_Click()
Dim frm As Form2
Set frm = New Form2
SetParent frm.hWnd, Picture1.hWnd
frm.Show
End Sub
' Unload all the Form2 forms.
Private Sub Form_Unload(Cancel As Integer)
Static unloading As Boolean
Dim i As Integer
If unloading Then Exit Sub
unloading = True
For i = Forms.Count - 1 To 0 Step -1
Unload Forms(i)
Next i
End Sub
|
|
The subforms behave a bit strangely when the user moves them, shrinks them, resizes the parent PictureBox, etc. You may want to remove their borders and arrange them explicitly in code.
|
|
|
|
|
|