473,383 Members | 1,832 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,383 software developers and data experts.

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
Sep 19 '05 #1
5 2216
Hi,

What about:

mainMID.Closing += new
System.ComponentModel.CancelEventHandler(this.Wind ow_Closing);

private void Window_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildren){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Address.com> wrote in message
news:uu**************@TK2MSFTNGP10.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

Sep 19 '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.ee> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.ComponentModel.CancelEventHandler(this.Wind ow_Closing);

private void Window_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildren){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Address.com> wrote in message
news:uu**************@TK2MSFTNGP10.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


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

"Ron L" <ro**@bogus.Address.com> wrote in message
news:eO**************@tk2msftngp13.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.ee> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.ComponentModel.CancelEventHandler(this.Wind ow_Closing);

private void Window_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Loop all childs and see if can close or save or ... do what you
need
foreach(Form frm in this.MdiChildren){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Address.com> wrote in message
news:uu**************@TK2MSFTNGP10.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



Sep 19 '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.ee> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
hild window is closed
directly?

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

"Ron L" <ro**@bogus.Address.com> wrote in message
news:eO**************@tk2msftngp13.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.ee> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
Hi,

What about:

mainMID.Closing += new
System.ComponentModel.CancelEventHandler(this.Wind ow_Closing);

private void Window_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Loop all childs and see if can close or save or ... do what you
need
foreach(Form frm in this.MdiChildren){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Address.com> wrote in message
news:uu**************@TK2MSFTNGP10.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



Sep 20 '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 ApplicationExiting(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.CancelEventArgs)
Handles _mainView.Closing
MessageBox.Show("Exiting the app!")
For Each frm As Form In _mainView.MdiChildren
frm.Close()
Next
End Sub

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

What about:

mainMID.Closing += new
System.ComponentModel.CancelEventHandler(this.Wind ow_Closing);

private void Window_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Loop all childs and see if can close or save or ... do what you need
foreach(Form frm in this.MdiChildren){
}
}

At least this works ok for me.

"Ron L" <ro**@bogus.Address.com> wrote in message
news:uu**************@TK2MSFTNGP10.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


Sep 20 '05 #6

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

Similar topics

3
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...
2
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...
3
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...
2
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....
5
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...
5
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...
5
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...
3
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.