c#实用开发(5)---Winfrom NotifyIcon 的使用
·
winform应用窗体默认无最小化到系统托盘的,而是在任务栏。
- 添加notifyIcon控件,给一个Icon,给一个点击事件
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
this.Show();
}
- form窗体给一个SizeChanged()事件,点击最小化按钮,会触发SizeChanged事件,在事件中将任务图标展示到托盘中,并隐藏窗体,关闭取消显示在任务栏上。
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false;
this.Hide();
this.notifyIcon1.Visible = true;
}
- notifyIcon 还具有气泡提示功能
this.notifyIcon1.ShowBalloonTip(3000, "运行成功", " ", ToolTipIcon.Info);

更多推荐



所有评论(0)