Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regd Serialization Pin
PandemoniumPasha20-Jun-07 0:21
PandemoniumPasha20-Jun-07 0:21 
QuestionRe: Regd Serialization Pin
vikasviswan20-Jun-07 0:30
vikasviswan20-Jun-07 0:30 
Questionmouse hook [modified] Pin
trecee_jhnsn19-Jun-07 20:27
trecee_jhnsn19-Jun-07 20:27 
Questiongetting data via DialUp Pin
Assaf Dar19-Jun-07 19:30
Assaf Dar19-Jun-07 19:30 
QuestionMDI Closing Statement Pin
*** AAMP ***19-Jun-07 19:16
*** AAMP ***19-Jun-07 19:16 
AnswerRe: MDI Closing Statement Pin
Nouman Bhatti19-Jun-07 20:20
Nouman Bhatti19-Jun-07 20:20 
GeneralRe: MDI Closing Statement Pin
*** AAMP ***19-Jun-07 22:34
*** AAMP ***19-Jun-07 22:34 
AnswerRe: MDI Closing Statement [modified] Pin
gumi_r@msn.com19-Jun-07 23:54
gumi_r@msn.com19-Jun-07 23:54 
The easiest way is handling all the closing logic by yourself and not rely on the Form's events. The order in which they are fired when closing an MDIParent window will not let you do what you want. As far as I know, unless they've changed it, you will be getting the Closing events of all the MDI child forms before you get the Closing event of the MDIParent, which is exactly the opposite of what you want.

This is a problem because normally all your logic linked to a closing form like for example requesting user validation in order to close, save, cancel, whatever, is linked to the Closing event, so you would have all these features popping up for each open MdiChild before you can do anything in your MdiParent Closing event.

Fortunately, its easy to solve: In pseudo code it would be something similar to this:

In your MdiParent Form:>

protected override void WndProc(ref Message m)
{
If m.Msg is WM_CLOSE (0x0010):
{
Show dialog window with closing options >> yes, no, no to all and store result in Answer
If Answer is cancel then m.Result = IntPrt.Zero and return without calling base WndProc.
Otherwise do all logic and supress closing warning messages on each MDI child form if necessary. (You'll need to code some kind of flag that will let you disable closing validation messages on your child forms. Then you simple iterate the MdiChildren collection disabling the flag)
}

Call base WndProc.
}

This way you have the advantage of handling the main form closing event before your mdichilds close 1 by 1. If this is the behaviour you always want then you are done.


-- modified at 5:59 Wednesday 20th June, 2007
Questioncan u convert this vb.net code into c#.net Pin
srinivassam19-Jun-07 18:45
srinivassam19-Jun-07 18:45 
AnswerRe: can u convert this vb.net code into c#.net Pin
Christian Graus19-Jun-07 19:05
protectorChristian Graus19-Jun-07 19:05 
Questionwriting to appconfig file Pin
justintimberlake19-Jun-07 18:41
justintimberlake19-Jun-07 18:41 
AnswerRe: writing to appconfig file Pin
Sathesh Sakthivel19-Jun-07 18:42
Sathesh Sakthivel19-Jun-07 18:42 
AnswerRe: writing to appconfig file Pin
Joseph Guadagno20-Jun-07 4:13
Joseph Guadagno20-Jun-07 4:13 
Questionwritng to appconfig file Pin
justintimberlake19-Jun-07 18:41
justintimberlake19-Jun-07 18:41 
QuestionWindowless Program Pin
Eric (eD)19-Jun-07 18:28
Eric (eD)19-Jun-07 18:28 
AnswerRe: Windowless Program Pin
Sathesh Sakthivel19-Jun-07 18:42
Sathesh Sakthivel19-Jun-07 18:42 
QuestionHow to Upload and Display File in C# ASP.Net 2005 Pin
Muhammad Chitrali19-Jun-07 18:03
Muhammad Chitrali19-Jun-07 18:03 
AnswerRe: How to Upload and Display File in C# ASP.Net 2005 Pin
Nouman Bhatti19-Jun-07 20:40
Nouman Bhatti19-Jun-07 20:40 
QuestionHow to write an Array to a file, fast? Pin
gire19-Jun-07 11:57
gire19-Jun-07 11:57 
AnswerRe: How to write an Array to a file, fast? Pin
Luc Pattyn19-Jun-07 12:24
sitebuilderLuc Pattyn19-Jun-07 12:24 
AnswerRe: How to write an Array to a file, fast? Pin
Jon Hulatt20-Jun-07 2:19
Jon Hulatt20-Jun-07 2:19 
GeneralRe: How to write an Array to a file, fast? Pin
gire20-Jun-07 11:05
gire20-Jun-07 11:05 
AnswerRe: How to write an Array to a file, fast? Pin
Hesham Yassin25-Jun-07 1:34
Hesham Yassin25-Jun-07 1:34 
QuestionBindingList over Remoting using an interface types Pin
MBursill19-Jun-07 10:43
MBursill19-Jun-07 10:43 
QuestionDelete From registry using C# (like "regedit" ) Pin
Iftekhar Naim19-Jun-07 9:53
Iftekhar Naim19-Jun-07 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.