I find this is the best approach.
protected override void WndProc(ref Message m)
{
const UInt32 WM_SYSCOMMAND = 0x112;
const UInt32 SC_MINIMIZE = 0xF020;
if ((m.Msg == WM_SYSCOMMAND) && ((UInt32)m.WParam == SC_MINIMIZE))
{
this.Hide();
return;
}
base.WndProc(ref m);
}
private void notifyIcon_DoubleClick(object sender, EventArgs e)
{
this.Show();
this.Activate();
}