使用NotifyIcon将窗口最小化到任务栏区域
2007-04-12 17:49
405 查看
采用NotifyIcon控件、记得要将窗体showintaskbar=true/false,它主要用来控制是否在任务栏显示。记得要给icon设置图片。
代码如下:
1 //窗体最小化事件
2 private void pbMinisize_Click(object sender, System.EventArgs e)
3 {
4 // Set the WindowState to normal if the form is minimized.
5 WindowState = FormWindowState.Minimized;
6 // 指示是否在Windows任务栏中显示窗体
7 this.ShowInTaskbar = false;
8 notifyIcon1.Visible = true;
9 }
10 #endregion
11
12 //任务栏区域的双击事件
13 private void notifyIcon1_DoubleClick(object Sender, EventArgs e)
14 {
15 // Show the form when the user double clicks on the notify icon.
16 if (this.WindowState == FormWindowState.Minimized)
17 this.WindowState = FormWindowState.Normal;
18 this.Activate();
19 this.ShowInTaskbar = true;
20 this.notifyIcon1.Visible = false;
21 }
用menuItem来设置任务栏区域的click菜单。
//退出
private void menuItem1_Click(object Sender, EventArgs e)
{
this.Close();
}
//打开
private void menuItem2_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Normal;
this.Activate();
this.ShowInTaskbar = true;
this.notifyIcon1.Visible = false;
}
代码如下:
1 //窗体最小化事件
2 private void pbMinisize_Click(object sender, System.EventArgs e)
3 {
4 // Set the WindowState to normal if the form is minimized.
5 WindowState = FormWindowState.Minimized;
6 // 指示是否在Windows任务栏中显示窗体
7 this.ShowInTaskbar = false;
8 notifyIcon1.Visible = true;
9 }
10 #endregion
11
12 //任务栏区域的双击事件
13 private void notifyIcon1_DoubleClick(object Sender, EventArgs e)
14 {
15 // Show the form when the user double clicks on the notify icon.
16 if (this.WindowState == FormWindowState.Minimized)
17 this.WindowState = FormWindowState.Normal;
18 this.Activate();
19 this.ShowInTaskbar = true;
20 this.notifyIcon1.Visible = false;
21 }
用menuItem来设置任务栏区域的click菜单。
//退出
private void menuItem1_Click(object Sender, EventArgs e)
{
this.Close();
}
//打开
private void menuItem2_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Normal;
this.Activate();
this.ShowInTaskbar = true;
this.notifyIcon1.Visible = false;
}
相关文章推荐
- 使用NotifyIcon将窗口最小化到任务栏区域 (转)
- delphi如何让程序最小化到任务栏(使用Shell_NotifyIcon API函数)
- delphi如何让程序最小化到任务栏(使用Shell_NotifyIcon API函数)
- vc 实现窗口最小化到任务栏
- 在网页中使用javascript打开没有最大化、最小化和关闭按钮的窗口
- QT窗口最小化后,不显示任务栏图标
- Windows窗体编程基础学习:使用 NotifyIcon 组件向任务栏添加应用程序图标
- Windows窗体编程基础学习:使用 NotifyIcon 组件向任务栏添加应用程序图标
- 高效程序员秘籍(2):使用GridMove快速将窗口以指定大小放到指定区域
- JFrame窗口,面板,标签,按钮,文本区域 使用
- 使用NotifyIcon轻松创建系统任务栏小图标
- WinForm 编程中控件的使用小技巧(splitter实现窗口分区域,改变Button的形状)
- ubuntu窗口最小化消失,任务栏上无法找到的解决方法
- 在C#中使用钩子实现Alt+F4健窗口最小化功能
- Qt中窗体最大最小化以及窗口大小修改的相关函数使用(2)
- 使用什么快捷键,关闭、打开、最小化qq聊天窗口
- VC非模态窗口最小化到任务栏
- 一种在注入进程中使用WTL创建无焦点不在任务栏出现“吸附”窗口的方法和思路
- Foxmail 关闭窗口最小化到任务栏
- 如何使对话框程序启动以及主窗口最小化时不在任务栏上显示