关闭窗口后隐藏(重载关闭窗口)
点击“close”或“Alt+F4”时,隐藏或最小化窗口,如:
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
{
// User clicked close button
// this.WindowState = FormWindowState.Minimized;//最小化
this.Hide();
return;
}
base.WndProc(ref m);
}