Can MDI be motified when child closes

  • Thread starter Thread starter SamSpade
  • Start date Start date
S

SamSpade

I need a MDI form to be notified when one of it's child closes.

I could define an event in each child and raise it when it closes.

But if there is some WinProc message that occurs when a child closes I would
rather use it and automate the process.


Second question. When a form Closed event occurs is the form then disposed.
I want to check the variable that references the form and if the form is
closed do a 'New"
So I'll check to see if it's disposed - right?

thanks
 
* " SamSpade said:
I need a MDI form to be notified when one of it's child closes.

I could define an event in each child and raise it when it closes.

\\\
Private m_Child As Form2

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Button1.Click
If m_Child Is Nothing Then
m_Child = New Form2()
m_Child .MdiParent = Me
AddHandler m_Child.Load, AddressOf Me.MdiChild_Load
AddHandler m_Child.Closed, AddressOf Me.MdiChild_Closed
End If
m_Child.Show() ' ...
End Sub

Private Sub MdiChild_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
)
MsgBox( _
"MdiChild with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" loaded!" _
)
End Sub

Private Sub MdiChild_Closed( _
ByVal sender As Object, _
ByVal e As System.EventArgs _
)
MsgBox( _
"MdiChild with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" closed!" _
)
End Sub
///
Second question. When a form Closed event occurs is the form then disposed.
I want to check the variable that references the form and if the form is
closed do a 'New"
So I'll check to see if it's disposed - right?

\\\
If <...>.IsDisposed Then
...
End If
///
 
Back
Top