I want to minimize the window when a user clicks the 'x' button in the control box. How can I prevent the window from closing?
thanks...
Printable View
I want to minimize the window when a user clicks the 'x' button in the control box. How can I prevent the window from closing?
thanks...
ok.. I found a solution by overriding the OnClosing function:
But I'm not sure if its enough, that is what happens when the program exits?Code:protected override void OnClosing( System.ComponentModel.CancelEventArgs e )
{
e.Cancel = true;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
}
Have you tried hooking the public event, CancelEventHandler. According to the remarks from the documentation:
Quote:
The Closing event occurs as the form is being closed. When a form is closed, all resources created within the object are released and the form is disposed. If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true.