拦截WINDOW消息 protected override void WndProc(ref Message m) { switch( m.Msg ) { case 0x0010: { WZorder.dal dal = new WZorder.dal(); if (ni.Visible != true)//NOTIFYICON { st st = new st(); st.ShowDialog(); st.StartPosition = FormStartPosition.CenterScreen;
this.Hide();
默认设置NotifyIcon.Visible=false;
设置一个NotifyIcon的图案在FormClosing事件里
e.Cancel = true;
Hide();
NotifyIcon.Visible = true;如果需要再让Form再显示,比如双击NotifyIcon显示,那就处理一下NotifyIcon的DoubleClick事件
NotifyIcon.Visible = false;
Show();
{
if(this.WindowState==FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}
} private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
protected override void WndProc(ref Message m)
{
switch( m.Msg )
{
case 0x0010:
{ WZorder.dal dal = new WZorder.dal();
if (ni.Visible != true)//NOTIFYICON
{ st st = new st();
st.ShowDialog();
st.StartPosition = FormStartPosition.CenterScreen;
else
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}
break;
}
default:
base.WndProc(ref m);
break; } }