BlakeMcKenna
asked on
Keeping Non-MDI forms within a Main form?
I am using non-MDI forms in my application only because the ability to add a MDI form has been disabled in the Project menu (don't know why either). Anyway, I have an active main form and when I show a new form....I wish for it to remain in the main form. I've seen an example of this before but can't remember where.
Thanks!
Thanks!
You can make a form a pseudo-mdi child using the SetParent() API:
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Dim f2 As New Form2
f2.Show
SetParent f2.hWnd, Me.hWnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim f As Form
For Each f In Forms
Unload f
Next f
End Sub
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Dim f2 As New Form2
f2.Show
SetParent f2.hWnd, Me.hWnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim f As Form
For Each f In Forms
Unload f
Next f
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://www.experts-exchange.com/questions/22052432/Visual-Basic-Forms.html