真个实现窗口最小化时自动最小化到托盘
真正实现窗口最小化时自动最小化到托盘
#region 最小化到托盘
const int WM_SYSCOMMAND = 0x0112;
const int SC_MINIMIZE = 0xF020;//最小化
const int SC_MAXIMIZE = 0xF030;//最大化
const int SC_RESTORE = 0xF120;//还原时
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_SYSCOMMAND)
{
int sc = m.WParam.ToInt32();
if (sc == SC_MINIMIZE)
{
this.Hide();
}
}
}
#endregion