文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | WPS | 杀毒软件
清风网络
首 页 软件下载 网络学院
QQ 电脑入门 游戏 操作系统 图形处理 办公软件 媒体动画 精文荟萃 工具软件 网络编程 程序开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络程序开发C/C++C#实现窗口最小化到系统托盘
精品推荐
特别推荐
·C语言编程常见问题解答之常用函数的包含文件(1)
·C语言编程易犯毛病集合
·C语言编程常见问题解答(目录)
·C#程序开发中的常用函数汇总
·C/C++笔试、面试题目大汇总
·Beej的网络socket编程指南
·socket编程原理
·C语言的常用库函数使用方法分析及用途
·在C语言中如何处理时间和日期
·C++设计模式之Singleton
热点TOP10
·C语言的常用库函数使用方法分析及用途
·C语言图形处理
·水滴石穿C语言之指针综合谈
·C语言编程常见问题解答之常用函数的包含文件(1)
·Windows下C语言网络编程快速入门
·进程调度模拟程序
·Visual C++ 入门精解
·C语言编程易犯毛病集合
·socket编程原理
·C语言编程常见问题解答(目录)

C#实现窗口最小化到系统托盘

日期:2007年12月21日 作者: 查看:[大字体 中字体 小字体]


C#编写最小化时隐藏为任务栏图标的 Window appllication.

1.设置WinForm窗体属性showinTask=false

2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。

3.添加窗体最小化事件(首先需要添加事件引用):

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

//上面一行是主窗体InitializeComponent()方法中需要添加的引用

private void Form1_SizeChanged(object sender, EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}
}

4.添加点击图标事件(首先需要添加事件引用):

private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}


5.可以给notifyIcon添加右键菜单:

主窗体中拖入一个ContextMenu控件NicontextMenu,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu 作为上下文菜单。

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.NicontextMenu = new System.Windows.Forms.ContextMenu();
this.menuItem_Hide = new System.Windows.Forms.MenuItem();
this.menuItem_Show = new System.Windows.Forms.MenuItem();
this.menuItem_Aubot = new System.Windows.Forms.MenuItem();
this.menuItem_Exit = new System.Windows.Forms.MenuItem();


this.notifyIcon1.ContextMenu = this.NicontextMenu;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject( "NotifyIcon.Icon ")));
this.notifyIcon1.Text = " ";
this.notifyIcon1.Visible = true;
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);


this.NicontextMenu.MenuItems.AddRange(

new System.Windows.Forms.MenuItem[]
{
this.menuItem_Hide,
this.menuItem_Show,
this.menuItem_Aubot,
this.menuItem_Exit
}
);

//
// menuItem_Hide
//
this.menuItem_Hide.Index = 0;
this.menuItem_Hide.Text = "隐藏 ";
this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);
//
// menuItem_Show
//
this.menuItem_Show.Index = 1;
this.menuItem_Show.Text = "显示 ";
this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);
//
// menuItem_Aubot
//
this.menuItem_Aubot.Index = 2;
this.menuItem_Aubot.Text = "关于 ";
this.menuItem_Aubot.Click += new System.EventHandler(this.menuItem_Aubot_Click);
//
// menuItem_Exit
//
this.menuItem_Exit.Index = 3;

[1] [2] 下一页 




上一篇:详解服务器集群系统实现方案

下一篇:非主流 中性性感MM装扮设计欣赏
相关文章:
·不用重装XP系统就可以解决全部故障
·打造极速XP系统之绝对秘籍
·XP系统运行慢?小编自用7招解决
·让Windows XP系统开口说话
·Windows操作系统应用技巧荟萃
·如何实现局域网打印机共享
·Win XP系统网络功能优化技巧
·装完操作系统需要做的几件大事
·XP系统登陆原理及其验证机制概述
·提高运行速度 教你一步一步优化XP系统
相关软件:

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.vipcn.net
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.vipcn.net All Rights Reserved. 鄂ICP备05000083号Powered by:viphot