private bool isExitApp = false;
private const int WM_QUERYENDSESSION = 0x0011;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_QUERYENDSESSION:
isExitApp = true;
break;
default:
base.WndProc(ref m);
break;
}
}
private void Form7_FormClosing(object sender, FormClosingEventArgs e)
{
if (!this.isExitApp)
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
this.Hide();
}
}