protected override void
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;
}
}
{
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;
}
}
本文介绍了一种将Windows窗体应用程序最小化至系统托盘的技术实现方法,并提供了具体的代码示例。通过该方法,可以实现在点击窗口最小化按钮时,将程序图标显示在任务栏的通知区域(系统托盘),而不是最小化到任务栏。
122

被折叠的 条评论
为什么被折叠?



