First I am curious why you would only want one form open at a time in an
mdi...
If you only want a single instance of the forms to open you are going about
it with a great amount of complexity. All you need is to add this to your
working form:
Private Sub New
End Sub
Private shared m_FrmSomeForm as frmSomeForm
private shared function GetInstance as frmSomeForm
if m_FrmSomeForm is nothing then
m_frmSomeForm=new frmSomeform
end if
return m_frmSomeform
end function
in your MDI:
dim frm as frmSomeForm
frm=frm.getinstance
That way you only have one instance of each form available. Then in the MDI
in your closing event:
e.cancel=false
then when you close your MDI all your child forms will close.
--
--Eric Cathell, MCSA
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi,
I have a mdi application in which it is only possible to open one form
at a time. To achieve this I have:
Public Class clsForms
Public Shared frm As Form
End Class
and then when I open a new form:
If Not form Is Nothing Then
If Not clsForms.frm Is Nothing Then
clsForms.frm.Close()
clsForms.frm = Nothing
End If
clsForms.frm = form
clsForms.frm.MdiParent = Me
clsForms.frm.Show()
clsForms.frm.Focus()
End If
It works fine except when I open a pop-up form from the toolbar of the
main form. When i do that, then if I try to open another form after i
closed the pop-up, clsForms.frm is not closed and i end up with having
multiple forms opened.
What is the problem with these pop-up (modal form) ?