473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2942
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: web_design | last post by:
I put this together from some other scripts I am using on a site. I'm trying to make a better email hiding script. It isn't working. Also, it causes Internet Explorer 6 SP2 to block the script...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
4
by: Tom | last post by:
I have a DLL that has a couple of class objects, and a few forms. When someone uses my DLL (i.e. puts a reference to it in their program), I want them to see the class objects that are public,...
5
by: Ivan | last post by:
I am used to VB6 and am not sure how to do this in Vstudio .NET. I have a main form which calls other forms. I want to disable that main form while other ones are called. I tried hiding it and...
1
by: c.verma | last post by:
I am not able to hide a href element using javascript. Here is my code written on aspx page. On the click of "OK" button, I want to hide href element. But I am getting message: Object required....
7
by: Steve954 | last post by:
I recently installed and started using VS2005 on a Windows XP Pro machine. When creating a new windows forms project I find that I am unable to hide any forms using the me.hide() or me.visible =...
14
by: Dom | last post by:
Hi all I'm developing a control, and I need to hide some properties to the user. For example, suppose I need Text property to be completely inacessible (from a Form/Code that is into another...
0
by: Jordi Rico | last post by:
Hi, I have an MDI Form which shows maximized mdi chil forms. I don't want these forms to show its own icon, and I am not able to hide it... Is there any way of hiding my forms icons??? Thanks
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.