Detect if MDI is open

  • Thread starter Thread starter alex
  • Start date Start date
A

alex

Hi,
how can I detect if an MDI is already open or not in order to prevent it
from being opened again.

How can I bring the MDI form to the TOP from the parent window.


If I do a
Dim myChildForm1 As New frmForm1()
myChildForm1.MdiParent = Me
myChildForm1.Show()

to startup the form in a Sub of the parent then i supposed I need to
store the reference somehow in order to access it later from a different
or even the same sub.

Can anyone give me a hand on that ?

Thanks

A
 
Hi A,

I gues you want to check if a 'Child' is open. (an MDI is the container-form
(parent))
I think the best practice is to create an accessible variable.
Look at the folowing code (you can put this in a genaral module)

If IsNothing(ChildForms.myChildForm1) Then

ChildForms.myChildForm1= New frmForm1

With ChildForms.myChildForm1

.MdiParent = ChildForms.frmMDI.ActiveForm

.Show()

.WindowState = wState

.StartPosition = FormStartPosition.CenterParent

End With

Else

' Child is instanciated so bring it back to top

ChildForms.myChildForm1.Activate()

End If

'Childforms' in this case is a "Shared Class". You can do the trick also
with 'plain' variables.
I use these classes because of readability and ease of use (eg:
intellisense)

HTH,

Michael


| Hi,
| how can I detect if an MDI is already open or not in order to prevent it
| from being opened again.
|
| How can I bring the MDI form to the TOP from the parent window.
|
|
| If I do a
| Dim myChildForm1 As New frmForm1()
| myChildForm1.MdiParent = Me
| myChildForm1.Show()
|
| to startup the form in a Sub of the parent then i supposed I need to
| store the reference somehow in order to access it later from a different
| or even the same sub.
|
| Can anyone give me a hand on that ?
|
| Thanks
|
| A
|
 
Back
Top