P
Phil
I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
TIA
Phil.
this in to detect when a child window is closed?
TIA
Phil.
I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
TIA
Phil.
Another one I'm wondering why?
The child forms should expose a FormClosed event that you could add an
event handler to when you add them to your mdi form.
Found it.Phil said:I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
"Phil" <N/A> wrote in message
Found it.
The MDIChildActivate event is fired each time a child window is closed, so I
can put my check in there.
I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
Since I also asked, I'll provide my reasoning. First off, I was just
plain curious - not much is normally done when all the mdi children
are closed, so I was just wondering what you were doing. Secondly, and
probably more importantly, knowing the reason why you are doing
something allows us to suggest a possible better way of achieving the
desired results. For example, if you mentioned you were looking at
open children to determine idle time, we could suggest something like
using the GetLastInputInfo API function.
rowe_newsgroups said:The MDIChildActivate will also fire at other times - not only when a
Child is closed.
Why not just use AddHandler to listen to the child's
FormClosed event? This event was built to notify listeners of this
specific event.
requirement. If a child window was opened, I set the visible property
to two toolbar icons on the Main Form's toolbar to true, these two
toolbar icons cause code to be called in the current active MDI child.
When the last child window was closed, I wanted to reset the visible
property to these two icons to false, so that they were only visible
if a child window was open.
I accomplished this task by:
1. Create a Integer property in the Main Form class that contained the
current number of active MDI children.
Any event in the Main Form that
created a child window bumped this counter up by one.
2. Create a property in the Child Form Class of the Main Form
datatype. In each event in the Main Form that created a child form,
before showing the form, I set this property to Me (the parent form).
3. In the Child Form's FormClosing Event, I added code to decrement
the parent form's current child window count by one, and if the value
is now zero, set the visible property of the two toolbar icons on the
Main Form's toolbar to false.
There may have been a simpler way to do it, but it has the distinct
property of working.
In my case, only the child form needed to know if it was the last
child window being closed, but since the proeprty that defines the
current number of open child windows was in the Main Form, any code in
the Main Form had access to it as well.
This property already exists (MdiChildren.Length) so you can simplify your
code by using this..
What happens if a child form is created in some other part of the code? You
would have to make the property public, or provide a public method to keep
track of it.
MdiChildren.Length is updated automatically.
Aren't you just duplicating the MDIParent property?
You would have to add this code to every child form. If you only have one
type of form that's OK I suppose. Better to have this code in the parent
really though.