473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching MDI Application Closing

I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window decide if
it should set cancel to true. The intent here is to ensure that no child
window can close while it is in a state where user entered information can
be lost. I have just noticed that while the Closing event is caught if I
click the X on the child window, it is not caught if I click the X on the
MDI parent window. Is there some other event that I am missing here?

Thanks,
Ron L
Nov 21 '05 #1
5 1192
Hi,

What about:

mainMID.Closing += new
System.Componen tModel.CancelEv entHandler(this .Window_Closing );

private void Window_Closing( object sender,
System.Componen tModel.CancelEv entArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildre n){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window decide
if it should set cancel to true. The intent here is to ensure that no
child window can close while it is in a state where user entered
information can be lost. I have just noticed that while the Closing event
is caught if I click the X on the child window, it is not caught if I click
the X on the MDI parent window. Is there some other event that I am
missing here?

Thanks,
Ron L

Nov 21 '05 #2
Ivar

Thanks for the response, I'll give it a try. Do you know why the Closing
event on the child windows only get thrown when the child window is closed
directly? I had thought that they would be thrown for any cause of the
window closing.

Ron L
"Ivar" <iv*@lumisoft.e e> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.Componen tModel.CancelEv entHandler(this .Window_Closing );

private void Window_Closing( object sender,
System.Componen tModel.CancelEv entArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildre n){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window decide
if it should set cancel to true. The intent here is to ensure that no
child window can close while it is in a state where user entered
information can be lost. I have just noticed that while the Closing event
is caught if I click the X on the child window, it is not caught if I
click the X on the MDI parent window. Is there some other event that I am
missing here?

Thanks,
Ron L


Nov 21 '05 #3
hild window is closed
directly? How you close window (I mean not dircetly)?
(Are you hidding or closing !)

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:eO******** ******@tk2msftn gp13.phx.gbl... Ivar

Thanks for the response, I'll give it a try. Do you know why the Closing
event on the child windows only get thrown when the child window is closed
directly? I had thought that they would be thrown for any cause of the
window closing.

Ron L
"Ivar" <iv*@lumisoft.e e> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.Componen tModel.CancelEv entHandler(this .Window_Closing );

private void Window_Closing( object sender,
System.Componen tModel.CancelEv entArgs e)
{
// Loop all childs and see if can close or save or ... do what you
need
foreach(Form frm in this.MdiChildre n){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window decide
if it should set cancel to true. The intent here is to ensure that no
child window can close while it is in a state where user entered
informatio n can be lost. I have just noticed that while the Closing
event is caught if I click the X on the child window, it is not caught if
I click the X on the MDI parent window. Is there some other event that I
am missing here?

Thanks,
Ron L



Nov 21 '05 #4
Ivar

I am closing the application, and all of its child windows, by clicking on
the "X" or Form.Close on the MDI Parent form. I had thought that the
application closing would fire a Closing event to each of the child windows,
but this is apparently not happening.

Thanks,
Ron L
"Ivar" <iv*@lumisoft.e e> wrote in message
news:%2******** **********@tk2m sftngp13.phx.gb l...
hild window is closed
directly?

How you close window (I mean not dircetly)?
(Are you hidding or closing !)

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:eO******** ******@tk2msftn gp13.phx.gbl...
Ivar

Thanks for the response, I'll give it a try. Do you know why the Closing
event on the child windows only get thrown when the child window is
closed directly? I had thought that they would be thrown for any cause
of the window closing.

Ron L
"Ivar" <iv*@lumisoft.e e> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.Componen tModel.CancelEv entHandler(this .Window_Closing );

private void Window_Closing( object sender,
System.Componen tModel.CancelEv entArgs e)
{
// Loop all childs and see if can close or save or ... do what you
need
foreach(Form frm in this.MdiChildre n){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window
decide if it should set cancel to true. The intent here is to ensure
that no child window can close while it is in a state where user entered
informati on can be lost. I have just noticed that while the Closing
event is caught if I click the X on the child window, it is not caught
if I click the X on the MDI parent window. Is there some other event
that I am missing here?

Thanks,
Ron L



Nov 21 '05 #5
Ivar

I tried the loop you suggested, but I still don't seem to be able to catch
the cancel from the individual windows closing to be able to keep the
application from exiting. Do you have any suggestions on this?

Here is my close handler:
' Catch the application exit event and gracefully close all MDI child
windows
Private Sub ApplicationExit ing(ByVal sender As System.Object, _
ByVal e As System.Componen tModel.CancelEv entArgs)
Handles _mainView.Closi ng
MessageBox.Show ("Exiting the app!")
For Each frm As Form In _mainView.MdiCh ildren
frm.Close()
Next
End Sub

Thanks,
Ron L
"Ivar" <iv*@lumisoft.e e> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.Componen tModel.CancelEv entHandler(this .Window_Closing );

private void Window_Closing( object sender,
System.Componen tModel.CancelEv entArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildre n){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
I have an MDI application with a number of child windows. In each child
window I am catching the Closing event and having the child window decide
if it should set cancel to true. The intent here is to ensure that no
child window can close while it is in a state where user entered
information can be lost. I have just noticed that while the Closing event
is caught if I click the X on the child window, it is not caught if I
click the X on the MDI parent window. Is there some other event that I am
missing here?

Thanks,
Ron L


Nov 21 '05 #6

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

Similar topics

3
5512
by: Wortelvisje | last post by:
Hello, What I want to do is quit simple: if the does clicks on the cross at the right top of the screen I want to catch this event and check a few things before closing the window. The only thing is, how can I detect somebody has clicked on it, and how can I possible prevent the window from closing without hiding the controlbox?
5
2261
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here is to ensure that no child window can close while it is in a state where user entered information can be lost. I have just noticed that while the Closing event is caught if I click the X on the child window, it is not caught if I click the X on...
2
2521
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the user wants to save the data, but when the Application closes this event isn't thrown automatically. I added a loop to close each child window, but can't seem find how to catch the child window's cancel of the Closing event, so even if the user...
3
17219
by: Elp | last post by:
Hi, I've developped a Window Form C# application which main form contains several activex controls. No problems most of the time but on some machine, the application crashes when the main form is closed with a NullReferenceException caused by the DisposeAxControl which, i guess, is supposed to dispose one of my ActiveX. This is not a big problem as the application is closing anyway but i'd like to suppress this crash message. However,...
2
1338
by: Silby | last post by:
Hi, I've a form.load event that initializes a cardreader, which is crucial to the operating of the program. Now if that throws an exception, the program needs to give a message and close down. I tried using Application.Exit(), but that happily executes the rest of the code (initializing a browser component and adding some images to buttons). Does anyone have any idea on how to make the program *really* shutdown without running anything...
5
2608
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing?
5
1693
by: Sam Samson | last post by:
Hi All, I have seen a few good behaviours for what to do in the case of those pesky uncaught exceptions. and I want to build some of these mechanisms into my Application that is currently out on the factory floor . What I'd like to do is catch that uncaught exception .. log the exception info and then pop up a window that is counting down to an application re-start that has a space for the operator to enter some info explaning just...
3
1827
by: Anthony P. | last post by:
Hello Everyone, I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET. When someone clicks the "Exit" menu option, which generates a button_click() event, I find it easy to display an "Are you sure?" MessgeBox before the application closes. That way, if they accidentally selected exit, they have a chance to back out. But I also want to catch the _closing() event on the form in case the user clicks the application close X...
0
10172
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.