protected override void
OnClosing(CancelEventArgs e )
{
this.WindowState =
FormWindowState.Minimized; //窗体状态最小化
e.Cancel =
true; //取消该事件,即取消onClosing事件
}
OnClosing(CancelEventArgs e )
{
this.WindowState =
FormWindowState.Minimized; //窗体状态最小化
e.Cancel =
true; //取消该事件,即取消onClosing事件
}
private
void contextMenuItemsClose_Click(object sender, System.EventArgs
e)
{
Application.Exit(); //notify控件的 ContextMenu
中要设置一个“关闭程序”的项目,否则无法退出
}
//监视窗体状态,当最小化时,到系统托盘
private void Form1_Resize(object sender,System.EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized){
this.Visible=false;
this.notifyIcon1.Visible =
true;
}else {
this.Visible =
true;
this.notifyIcon1.Visible =
false;
}
}