Code:-
public const int SC_CLOSE = 0xF060;
public const int WM_SYSCOMMAND = 0x0112;
//Override method when You will close the window
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
//close the application
MyClose();
// your method that cleans everything up and then runs
// System.Environment.Exit(0) which WILL close the threads forcefully if needed
base.WndProc(ref m);
}
0 comments:
Post a Comment