469,578 Members | 1,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Hiding MDI forms

I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.
Jun 24 '06 #1
11 2749
Kevin,

I try to avoid the my namespace, it is mainly created for VB6 developers,
while there were already good solutions, which are in my opinion less
confusing when you want to use OOP. (In some cases the my namespace has
handy features so don't understand me wrong).

In your parent you can use the mdichildren instead of that openforms

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

This msdn page is in my idea confusing. It has to be me.mdichildren or just
mdichildren

There are more properties around the MDI form which are easy for you with
what you are busy,

I hope this helps,

Cor
"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:2h********************************@4ax.com...
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 24 '06 #2
I tried that too. The only problem is, I can't seem to open a
MDIChild form modally. I have to make them non-child forms to open
them modally, so they don't end up in the MDIChildren collection.
On Sat, 24 Jun 2006 07:16:02 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Kevin,

I try to avoid the my namespace, it is mainly created for VB6 developers,
while there were already good solutions, which are in my opinion less
confusing when you want to use OOP. (In some cases the my namespace has
handy features so don't understand me wrong).

In your parent you can use the mdichildren instead of that openforms

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

This msdn page is in my idea confusing. It has to be me.mdichildren or just
mdichildren

There are more properties around the MDI form which are easy for you with
what you are busy,

I hope this helps,

Cor
"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:2h********************************@4ax.com.. .
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 24 '06 #3
you can't make a child form a modal form, its impossible... modal has to
have top level access and all parents behind it lose access at that time
(they get locked out of gaining focus) this is impossible to do when it is a
child of a MDI form inside a MDI window..
"Kevin" <ke****@cfl.rr.com> wrote in message
news:7u********************************@4ax.com...
I tried that too. The only problem is, I can't seem to open a
MDIChild form modally. I have to make them non-child forms to open
them modally, so they don't end up in the MDIChildren collection.
On Sat, 24 Jun 2006 07:16:02 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Kevin,

I try to avoid the my namespace, it is mainly created for VB6 developers,
while there were already good solutions, which are in my opinion less
confusing when you want to use OOP. (In some cases the my namespace has
handy features so don't understand me wrong).

In your parent you can use the mdichildren instead of that openforms

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

This msdn page is in my idea confusing. It has to be me.mdichildren or
just
mdichildren

There are more properties around the MDI form which are easy for you with
what you are busy,

I hope this helps,

Cor
"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:2h********************************@4ax.com. ..
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 24 '06 #4
I bet you anything your exception is because you are modifying the
collection and the enumeration is changing

for each depends on the enumeration it stay constant... you cant change it
during the loop... so when you hide a form its probably removing it from the
enumeration of open forms and its like oh look i change cant keep going...
this also applies to looping through other collection enumerations like list
box items and such and like removing an item from the list while you are
going through it... the only way around it is drop the for each and use a
for i as integer = 0 to my.application.openforms.count -1 type of loop
this will not be affected by the collection changing like for each is
Jun 24 '06 #5
I started to do the For Next loop, but I'm not real sure how to call
each form.
On Sat, 24 Jun 2006 15:17:50 -0400, "Smokey Grindle"
<no****@dontspamme.com> wrote:
I bet you anything your exception is because you are modifying the
collection and the enumeration is changing

for each depends on the enumeration it stay constant... you cant change it
during the loop... so when you hide a form its probably removing it from the
enumeration of open forms and its like oh look i change cant keep going...
this also applies to looping through other collection enumerations like list
box items and such and like removing an item from the list while you are
going through it... the only way around it is drop the for each and use a
for i as integer = 0 to my.application.openforms.count -1 type of loop
this will not be affected by the collection changing like for each is

Jun 25 '06 #6
Than if you don't have MDI forms, why is your question about that?

Cor

"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:7u********************************@4ax.com...
I tried that too. The only problem is, I can't seem to open a
MDIChild form modally. I have to make them non-child forms to open
them modally, so they don't end up in the MDIChildren collection.
On Sat, 24 Jun 2006 07:16:02 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Kevin,

I try to avoid the my namespace, it is mainly created for VB6 developers,
while there were already good solutions, which are in my opinion less
confusing when you want to use OOP. (In some cases the my namespace has
handy features so don't understand me wrong).

In your parent you can use the mdichildren instead of that openforms

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

This msdn page is in my idea confusing. It has to be me.mdichildren or
just
mdichildren

There are more properties around the MDI form which are easy for you with
what you are busy,

I hope this helps,

Cor
"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:2h********************************@4ax.com. ..
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 25 '06 #7
On Sun, 25 Jun 2006 00:17:33 GMT, Kevin <ke****@cfl.rr.com> wrote:
I started to do the For Next loop, but I'm not real sure how to call
each form.

For Each ChildForm As Form In Me.MdiChildren
ChildForm.Visible = False
Next
Gene


On Sat, 24 Jun 2006 15:17:50 -0400, "Smokey Grindle"
<no****@dontspamme.com> wrote:
I bet you anything your exception is because you are modifying the
collection and the enumeration is changing

for each depends on the enumeration it stay constant... you cant change it
during the loop... so when you hide a form its probably removing it from the
enumeration of open forms and its like oh look i change cant keep going...
this also applies to looping through other collection enumerations like list
box items and such and like removing an item from the list while you are
going through it... the only way around it is drop the for each and use a
for i as integer = 0 to my.application.openforms.count -1 type of loop
this will not be affected by the collection changing like for each is

Jun 25 '06 #8
you can access them by index...

for i as integer = 0 to my.application.openforms.count -1
my.application.openforms(i).visible = false
next

"Kevin" <ke****@cfl.rr.com> wrote in message
news:lf********************************@4ax.com...
I started to do the For Next loop, but I'm not real sure how to call
each form.
On Sat, 24 Jun 2006 15:17:50 -0400, "Smokey Grindle"
<no****@dontspamme.com> wrote:
I bet you anything your exception is because you are modifying the
collection and the enumeration is changing

for each depends on the enumeration it stay constant... you cant change it
during the loop... so when you hide a form its probably removing it from
the
enumeration of open forms and its like oh look i change cant keep going...
this also applies to looping through other collection enumerations like
list
box items and such and like removing an item from the list while you are
going through it... the only way around it is drop the for each and use a
for i as integer = 0 to my.application.openforms.count -1 type of loop
this will not be affected by the collection changing like for each is

Jun 25 '06 #9
I have MDI forms , but occasionally I have to show a form modally. NOT
EVERY form can be a MDI Child form!
On Sun, 25 Jun 2006 07:16:10 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Than if you don't have MDI forms, why is your question about that?

Cor

"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:7u********************************@4ax.com.. .
I tried that too. The only problem is, I can't seem to open a
MDIChild form modally. I have to make them non-child forms to open
them modally, so they don't end up in the MDIChildren collection.
On Sat, 24 Jun 2006 07:16:02 +0200, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
Kevin,

I try to avoid the my namespace, it is mainly created for VB6 developers,
while there were already good solutions, which are in my opinion less
confusing when you want to use OOP. (In some cases the my namespace has
handy features so don't understand me wrong).

In your parent you can use the mdichildren instead of that openforms

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

This msdn page is in my idea confusing. It has to be me.mdichildren or
just
mdichildren

There are more properties around the MDI form which are easy for you with
what you are busy,

I hope this helps,

Cor
"Kevin" <ke****@cfl.rr.com> schreef in bericht
news:2h********************************@4ax.com ...
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 25 '06 #10
How can I reference them by name? If I put the names of all open forms
into a string array, how can I go back through the list and change
their Visible property back to True?
On Sun, 25 Jun 2006 11:18:54 -0400, "Smokey Grindle"
<no****@dontspamme.com> wrote:
you can access them by index...

for i as integer = 0 to my.application.openforms.count -1
my.application.openforms(i).visible = false
next

"Kevin" <ke****@cfl.rr.com> wrote in message
news:lf********************************@4ax.com.. .
I started to do the For Next loop, but I'm not real sure how to call
each form.
On Sat, 24 Jun 2006 15:17:50 -0400, "Smokey Grindle"
<no****@dontspamme.com> wrote:
I bet you anything your exception is because you are modifying the
collection and the enumeration is changing

for each depends on the enumeration it stay constant... you cant change it
during the loop... so when you hide a form its probably removing it from
the
enumeration of open forms and its like oh look i change cant keep going...
this also applies to looping through other collection enumerations like
list
box items and such and like removing an item from the list while you are
going through it... the only way around it is drop the for each and use a
for i as integer = 0 to my.application.openforms.count -1 type of loop
this will not be affected by the collection changing like for each is

Jun 25 '06 #11
Hello, Kevin,

I suggest that you try something like the following. Sorry I haven't
tested this because I'm not currently using 2005. :-( Worse, I don't
seem to be able to open MSDN just now to check whether or not OpenForms
has an array nature or a collection nature. If the latter, try changing
my use of "Length" to "Count".

Dim IndexOfNonMainForm As Integer = 0
While Me.MdiChildren.Length > 1
Dim m As Form = MdiChildren(IndexOfNonMainForm)
If (m.Name = "frmMain") Then
IndexOfNonMainForm = 1
m = MdiChildren(IndexOfNonMainForm)
End If
m.Visible = False
End While

Cheers,
Randy
Kevin wrote:
I've got a timer on my MDI parent form. If there's no mouse movement
for a set number of minutes, the Visible property of all open forms is
set to False and the Log On form is displayed. I could do it in VB6.

In VB2005 I can get a list of all the open forms, but I get an error
after hiding the first one.

This is what I'm trying to use:

For Each m In My.Application.OpenForms
If m.Name <> "frmMain" Then
m.Visible = False
End If
Next m

It won't list all the open forms if one of the child forms is showing
another modal form. And again, once it hides the first form, it bombs
out--something about my OpenForms collection changing.

Jun 26 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by web_design | last post: by
17 posts views Thread by Bob Weiner | last post: by
22 posts views Thread by Mr Newbie | last post: by
1 post views Thread by c.verma | last post: by
7 posts views Thread by Steve954 | last post: by
14 posts views Thread by Dom | last post: by
reply views Thread by Jordi Rico | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.