http://beta.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q
_20407745.html
To quote from that page.
--
To hide the window when the user presses the close button (X) subscribe to
the Form's Closing event...
(C#)
this.Closing += new
System.ComponentModel.CancelEventHandler(this.Form1_Closing);
Then in the event handler hide the form, and cancel the close... Be careful
as this code alone will prevent you from ever closing the application,
somewhere you need to provide a way of closing the form, maybe use a flag
which can be tested in this event handler to determine whether or not the
event should be cancelled.
(C#)
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
// Hide the form...
this.Hide();
// Cancel the close...
e.Cancel = true;
}
You might also want to look at the following question/answer which describes
how to put an icon in the system tray
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_
20397858.html
As for the second part of your question...
The Form.Close() method will simply close that form and all resources
created within the object are closed and the form is disposed.
The Application.Exit() method informs all message pumps that they must
terminate, and then closes ALL application windows after the messages have
been processed. It is usually recommended that Form.Close() is called for
each form individually before calling Application.Exit().
If you need to get out of an application quick and don't care about cleaning
up (closing files, etc) then you can use Application.Exit(). The more usual
case would be to do a controlled Form.Close() of the main Form letting the
application come to a natural end.
--
Jack Meyhoff said:
the [X] button is the same as WM_SYSTEM -> SC_CLOSE in win32 messaging.
RAJ T said:
hi Jack Meyhoff
i had seen these MSDN pages but i m still confused
how i will know this is X button of form or something else...
bye