WEll to catch the X in the corner you have to override the OnClosing Event
Here's some that I use:
Basically, as long as the compute risn't shutting down (sessionEnding) it just hides the form.Code:protected override void OnClosing(CancelEventArgs e) { log.Debug(String.Format("Onclosing called, this.sessionEnding = {0}",this.sessionEnding)); if (this.sessionEnding) { //Windows IS shutting down e.Cancel = false; this.ShutDown(); } else //windows isn't closing { //Method overridden so we can minimize the app instead of closing it e.Cancel = true; //let's minimize the form, and hide it this.WindowState = FormWindowState.Minimized; Hide(); } }
And for Alt-F4 you will have to write a OnKeyDown Event handler and attachit to whatever might had focus when the user presses alt-f4
Code:private void ConversationDisplayBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs kea) { if (kea.Alt & (kea.Code == *whatever F4 equals*)) { } }




Reply With Quote