Thanks for the suggestions. However, there was a problem in that the MDI
child forms were not being built by me and so I did not have control over
what the classes contained and couldn't enforce that all of the individual
MDI children implement their own protection against user closing. It turned
out that there is an easier way to handle the situation. Each MDI child has
an event notification list that is happy to accept an additional event
handler that resides in the main application. At the time that I created the
MDI child window(s) I also appended my own handler to the child's event
notification list. This gives something like this:
// In the code that creates an MDI child...
childForm.FormC losing += New FormClosingEven tHandler(
ChildFormClosin gEventhandler );
// Later in the module, the actual event handler itself...
public void ChildFormClosin gEventHandler(O bject sender, FormClosingEven tArgs
e)
{
if (CloseReason.Us erClosing == e.CloseReason)
e.Cancel = true;
}
Works like a champ!
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
"Ben Voigt" <rb*@nospam.nos pamwrote in message
news:ey******** ******@TK2MSFTN GP03.phx.gbl...
>
"DeveloperX " <nn*****@operam ail.comwrote in message
news:11******** ************@m7 g2000cwm.google groups.com...
>Add code to the Closing evening for the child form and set e.cancel =
true; in those cases you don't want it to close.
Use the FormClosing event so you get CloseReason:
ApplicationExit Call The Exit method of the Application class was invoked.
FormOwnerClosin g The owner form is closing.
MdiFormClosing The parent form of this multiple document interface (MDI)
form is closing.
None The cause of the closure was not defined or could not be determined.
TaskManagerClos ing The Microsoft Windows Task Manager is closing the
application.
UserClosing The user is closing the form through the user interface (UI),
for example by clicking the Close button on the form window, selecting
Close from the window's control menu, or pressing ALT+F4.
WindowsShutDown The operating system is closing all applications before
shutting down.
Then test for UserClosing
>>
Richard Lewis Haggard wrote:
>>Is there an easy way to disable the hotkey sequence Control F4 or
otherwise
prevent the action from killing off MDI child windows in VS05/WinForms
2?
I've already figured out how to get rid of the 'x' in the caption bar
but
the hot key sequence is still allowing users to kill off MDI child
windows,
which I need to prevent from happening.
--
Richard Lewis Haggard
www.Haggard-And-Associates.com