I have a custom use application I am developing, but I'm having a problem with some child forms. I have one child form (an output console) that needs to be opened to see the debugging output. I have no problem getting the form to open, minimize, etc. but, I cannot keep it from releasing it's resources when you click the close (X) button. I DO NOT want to disable the button. What I have done is setup an event handler for when the form closes. Instead of closing, it hides the window. However, as soon as the window is hidden once, if you try to show (form.show() or form.visible = true;) it errors out and the application locks up. The error message from VS08 is: System.ObjectDisposedExcep
tion was unhandled. The object that was unhandled is the form I want to show. I'm guessing what is happening is it is getting disposed before the code comes in from my event handler (e.cancel():) So, I'm guessing my only option is to somehow trap the close button and never initiate a close to being with. If I could force it to only hide, that should be perfect. I've searched for days on end and cannot find any solutions other than disabling the close button (again, CAN NOT do this) or handling the closing event like I'm already doing.
Below is the code for my event hanlder:
private void consoleForm_FormClosing(object sender, FormClosingEventArgs e)
e.Cancel = true;