|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hiding MDI formsI'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. 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/library/system.windows.forms.form.mdichildren.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 Show quoteHide quote "Kevin" <kev***@cfl.rr.com> schreef in bericht news:2h0p92pk0kn1n3jrlmhk7te5t81fk8kjeb@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. 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]" <notmyfirstn***@planet.nl> wrote: Show quoteHide quote >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/library/system.windows.forms.form.mdichildren.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" <kev***@cfl.rr.com> schreef in bericht >news:2h0p92pk0kn1n3jrlmhk7te5t81fk8kjeb@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. > 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.. Show quoteHide quote "Kevin" <kev***@cfl.rr.com> wrote in message news:7unq929krac12c4caijmt57gveins9m6d3@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]" > <notmyfirstn***@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/library/system.windows.forms.form.mdichildren.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" <kev***@cfl.rr.com> schreef in bericht >>news:2h0p92pk0kn1n3jrlmhk7te5t81fk8kjeb@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. >> Than if you don't have MDI forms, why is your question about that?
Cor Show quoteHide quote "Kevin" <kev***@cfl.rr.com> schreef in bericht news:7unq929krac12c4caijmt57gveins9m6d3@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]" > <notmyfirstn***@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/library/system.windows.forms.form.mdichildren.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" <kev***@cfl.rr.com> schreef in bericht >>news:2h0p92pk0kn1n3jrlmhk7te5t81fk8kjeb@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. >> 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]" <notmyfirstn***@planet.nl> wrote: Show quoteHide quote >Than if you don't have MDI forms, why is your question about that? > >Cor > >"Kevin" <kev***@cfl.rr.com> schreef in bericht >news:7unq929krac12c4caijmt57gveins9m6d3@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]" >> <notmyfirstn***@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/library/system.windows.forms.form.mdichildren.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" <kev***@cfl.rr.com> schreef in bericht >>>news:2h0p92pk0kn1n3jrlmhk7te5t81fk8kjeb@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. >>> > 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 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" <nospam@dontspamme.com> wrote: Show quoteHide quote >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 > On Sun, 25 Jun 2006 00:17:33 GMT, Kevin <kev***@cfl.rr.com> wrote:
>I started to do the For Next loop, but I'm not real sure how to call For Each ChildForm As Form In Me.MdiChildren>each form. > ChildForm.Visible = False Next Gene Show quoteHide quote > >On Sat, 24 Jun 2006 15:17:50 -0400, "Smokey Grindle" ><nospam@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 >> you can access them by index...
for i as integer = 0 to my.application.openforms.count -1 my.application.openforms(i).visible = false next Show quoteHide quote "Kevin" <kev***@cfl.rr.com> wrote in message news:lflr92dvub50h5fjsehbr7c02ftnqt4129@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" > <nospam@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 >> 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" <nospam@dontspamme.com> wrote: Show quoteHide quote >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" <kev***@cfl.rr.com> wrote in message >news:lflr92dvub50h5fjsehbr7c02ftnqt4129@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" >> <nospam@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 >>> > 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: Show quoteHide quote > 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.
Global variables
numbers investigation Something tricky! change DataSet Row background color Multilanguage support Mulitp app.config files in multiple project solution Response.Redirect not being called after sending an email missing System.Security.Cryptography.Xml namespace REGISTRY - TemporaryInternetFiles vb2005 - how to rehide Form constructor after exposing it? -not co |
|||||||||||||||||||||||