473,574 Members | 18,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Know when an mdi child closes?

How can the MDI parent form know when an MDI child closes?

I need to know when the last one closes because I have something on the MDI
form that I need to clear out when all children are closed...

Thanks,

Shane
Nov 21 '05 #1
10 7135
Hi,

there are more ways to solve this.
you can use a global counter and increment or decrement it while opening and
closing forms.
but there is a build in counter in the MDIParent window. use these to get
the mdiclient forms count:

[ParentFormName].MdiChildren.Le ngth

Use a callback from mdichilds or something like that to inform the parent
window.
this can be done with subclassing or eventhandlers for the windows. its up
to you...

check this for more information:

http://msdn.microsoft.com/library/de...ldrenTopic.asp

This is the best solution without any workaround...

Best regards

Kerem Gümrükcü
Nov 21 '05 #2
Yes... well I am need notification. There is no MdiChildClosed event
There is the MdiChildActivat ed.....
bummer...

Guess I will have to have the child call the parent someway to say closing
and then see if any children are open.

Shane
"Kerem Gümrükcü" <ka*******@hotm ail.com> wrote in message
news:uj******** *****@tk2msftng p13.phx.gbl...
Hi,

there are more ways to solve this.
you can use a global counter and increment or decrement it while opening and closing forms.
but there is a build in counter in the MDIParent window. use these to get
the mdiclient forms count:

[ParentFormName].MdiChildren.Le ngth

Use a callback from mdichilds or something like that to inform the parent
window.
this can be done with subclassing or eventhandlers for the windows. its up
to you...

check this for more information:

http://msdn.microsoft.com/library/de...ldrenTopic.asp
This is the best solution without any workaround...

Best regards

Kerem Gümrükcü

Nov 21 '05 #3
Shane,

I did not try this, however I would try it raising a public event in my
clossing event and catch that in my mainMDI form, when I had this to solve.

I hope this helps a little bit.

Cor
Yes... well I am need notification. There is no MdiChildClosed event
There is the MdiChildActivat ed.....
bummer...

Guess I will have to have the child call the parent someway to say closing
and then see if any children are open.

Shane
"Kerem Gümrükcü" <ka*******@hotm ail.com> wrote in message
news:uj******** *****@tk2msftng p13.phx.gbl...
Hi,

there are more ways to solve this.
you can use a global counter and increment or decrement it while opening

and
closing forms.
but there is a build in counter in the MDIParent window. use these to get the mdiclient forms count:

[ParentFormName].MdiChildren.Le ngth

Use a callback from mdichilds or something like that to inform the parent window.
this can be done with subclassing or eventhandlers for the windows. its up to you...

check this for more information:

http://msdn.microsoft.com/library/de...ldrenTopic.asp

This is the best solution without any workaround...

Best regards

Kerem Gümrükcü


Nov 21 '05 #4
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> skrev i en meddelelse
news:OE******** ******@tk2msftn gp13.phx.gbl...
Yes... well I am need notification. There is no MdiChildClosed event
There is the MdiChildActivat ed.....
bummer...


Take a closer look at the docs on the MdiChildActivat e event:

"Occurs when a multiple document interface (MDI) child form is activated or
closed within an MDI application."

Source:
http://msdn.microsoft.com/library/en...ivateTopic.asp

So you DO get an event, when the MDI child closes.

/Jens
--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk
Nov 21 '05 #5
* "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> scripsit:
How can the MDI parent form know when an MDI child closes?


See (complete thread):

<URL:http://www.google.de/groups?threadm= %23YhPW6KSEHA.1 388%40TK2MSFTNG P09.phx.gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #6
Shane,
I would use the techniques mentioned in the Thread that Herfried showed.

The sample Herfried mentions assuming that there will only be one instance
of the child, if you can have multiple instances of the child forms, instead
of m_child As Form2 you may want to keep a collection of children...

As Jens pointed out, I think the MdiChildActivat ed event will also tell you
what you want.

Hope this helps
Jay

"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How can the MDI parent form know when an MDI child closes?

I need to know when the last one closes because I have something on the MDI form that I need to clear out when all children are closed...

Thanks,

Shane

Nov 21 '05 #7
Hey man--this is good news!! Thanks a bunch I will try it out.
Most importantly I am needing to know when the last one has closed to clean
up shared resources.

Thanks... I will check it out.

Shane
"Jens Christian Mikkelsen" <je*********@jc mikkelsenNoSpam Please.dk> wrote in
message news:uI******** ******@TK2MSFTN GP12.phx.gbl...
"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> skrev i en meddelelse news:OE******** ******@tk2msftn gp13.phx.gbl...
Yes... well I am need notification. There is no MdiChildClosed event
There is the MdiChildActivat ed.....
bummer...
Take a closer look at the docs on the MdiChildActivat e event:

"Occurs when a multiple document interface (MDI) child form is activated

or closed within an MDI application."

Source:
http://msdn.microsoft.com/library/en...ivateTopic.asp
So you DO get an event, when the MDI child closes.

/Jens
--
Jens Christian Mikkelsen
http://www.jcmikkelsen.dk

Nov 21 '05 #8
Yeah... it thought about the forms collection but doesn't mdi parent already
have a collection? So seems like duplication for nothing and my real issue
was being informed of when one closed so I could decide if it were the last
one.

I think Jens's suggestion may be just what I need and I can check
mdichildren count or whatever the mdichild collection is named--I'm not in
the IDE right now...

Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:Og******** ******@TK2MSFTN GP12.phx.gbl...
Shane,
I would use the techniques mentioned in the Thread that Herfried showed.

The sample Herfried mentions assuming that there will only be one instance
of the child, if you can have multiple instances of the child forms, instead of m_child As Form2 you may want to keep a collection of children...

As Jens pointed out, I think the MdiChildActivat ed event will also tell you what you want.

Hope this helps
Jay

"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How can the MDI parent form know when an MDI child closes?

I need to know when the last one closes because I have something on the

MDI
form that I need to clear out when all children are closed...

Thanks,

Shane


Nov 21 '05 #9
hmm..

Adding a handler to the MDI child that points back to the MDI parent sounds
like a good potential.

Now when I do this....if also in the MDIchild's close event I put some code,
would both execute and which would be first?

Thanks,

Shane

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:2o******** ****@uni-berlin.de...
* "SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> scripsit:
How can the MDI parent form know when an MDI child closes?
See (complete thread):

<URL:http://www.google.de/groups?threadm=...TK2MSFTNGP09.p
hx.gbl>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2119
by: FamB | last post by:
I have this PHP code (PHP5): if($autologin == "on") session_set_cookie_params(60*60*24*365); // 365 days else session_set_cookie_params(0); // when browser closes session_start(); In my php.ini file I have this line, which I guess will give me a 365 days timeout on my PHPSESSID server session:
3
2505
by: Kiki | last post by:
Hello, i wonder if anyone can help.. Is there a way of knowing from the parent window (var window;) that the child window (var newWindow) has been closed? i can't touch the child window's closed as this will be populated and managed by a client.. i need to know when this will be closed though to reload the parent window.. thanks
1
3362
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of normal window. Actually, I tried to close the parent window from the child modal window using parent.close syntax in onload event in child modal...
2
2434
by: John Dalberg | last post by:
I have a closed box system which opens an html page. The page closes by the system. I have access to the html page. I added code to open a child window from this page. However when the parent window closes, the child closes too. Is there a way to keep the child window open? Yes keep it orphaned. -- John Dalberg
1
1885
by: feng | last post by:
Hi, When user closes a browser window by clicking on the "X" button, I want the server to be noticed (either through postback or calling other ASP pages, etc.) and perform some task accordingly. Please note that I can't use session end event, since the session is still alive now and the user is just closing a secondary window he/she...
3
2571
by: Charlie | last post by:
Hi: I would like to clear session when user closes browser window by clicking the "x" in upper right hand corner. Since this is a client side event, how do I run server code (Session.Abandon()) when user clicks "x"? Thanks, Charlie
1
1413
by: SamSpade | last post by:
I need a MDI form to be notified when one of it's child closes. I could define an event in each child and raise it when it closes. But if there is some WinProc message that occurs when a child closes I would rather use it and automate the process. Second question. When a form Closed event occurs is the form then disposed. I want to...
3
2021
by: ray well | last post by:
hi, i have a app which has a help file, *.hlp, which the user can launch within the program. i want the help file if it is open to close when the program exists. the way i did it till now is by running the following code when the program closes Dim proc, procs() As Process
1
1327
by: robc2236 | last post by:
ok i am making a program to manage my mame roms that runns in fullscreen the problem is when i play a rom from it my program minimizes and stays minimized even when mame has closed is there any way i can add some code to my prgram so when mame closes for my program to go back to fullscreen automatically
0
7817
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8081
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8258
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8119
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6482
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2254
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.