惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
G
GRAHAM CLULEY
S
Securelist
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
博客园 - 叶小钗
B
Blog RSS Feed
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
K
Kaspersky official blog
D
Docker
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
H
Help Net Security
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
美团技术团队
腾讯CDC

博客园 - 太白飞仙

.Net网络资源 CI创意的方法与技巧 可控人生核聚变 用c#备份和还原sql server 2000数据库 论文先睹:关于科学的生命哲学的思考 蚂蚁造山的思考 语言争霸VS魔兽争霸 :: IT世界VS魔兽世界 第九章 SQL Server的简单应用 [导入]文章藏金阁 [导入]敏捷实验室的一次争论 [导入]Netron研究(四)----"移动和联通"之联通篇 [导入]Netron研究(二)----"容器"登场 [导入]Netron研究(一)----初识 [导入]Netron研究(三)----"移动和联通"之移动篇 [导入]Agile Framework的日志服务 [导入]Agile Framework工作流服务的设计思路 [导入]KISS原则 [导入]WWF工作流引擎的一个奇怪现象 - 太白飞仙 - 博客园 [导入]时刻提防过度设计
[导入]类型MSN窗体行为的实现(.NET 2.0) - 太白飞仙 - 博客园
太白飞仙 · 2006-01-16 · via 博客园 - 太白飞仙

    当我们点击MSN窗体的"X"关闭程序时,MSN并不退出,而是最小化窗体,并且不在任务栏上显示.托盘区显示该程序.现在,我用VS2005实现类似的效果.
    .NET 2.0的窗体中多了一个"ShowInTaskbar"的属性,指示该应用程序是否显示在任务栏.有了这个属性,我们的实现就简单多了.
    首先,把窗体的ShowInTaskbar属性设为False,然后添加一个NotifyIcon控件,一个Menu控件,一个ContextMenu控件(用于和NotifyIcon关联).Menu和ContextMenu都只添加一个"Exit"菜单项,来控制窗体的行为.
    部分代码如下:

    窗体关闭事件代码

private void Form1_FormClosing(object sender, FormClosingEventArgs e) { //窗体关闭事件 if (this.WindowState != FormWindowState.Minimized) { e.Cancel = true; this.WindowState = FormWindowState.Minimized; this.notifyIcon1.ShowBalloonTip(3000, "My App",

               "My App is not closed.\n it's minimized!", ToolTipIcon.Info); } }

    双击托盘区图标时间代码

private void notifyIcon1_DoubleClick(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.ShowInTaskbar = true; //重新显示窗口 this.Show(); this.WindowState = FormWindowState.Normal; } this.Activate();//激活窗口 this.Focus(); }

    点击Menu和ContextMenu的"Exit"菜单项事件

private void exitToolStripMenuItem_Click(object sender, EventArgs e) { //点击菜单中的"Exit"事件 this.WindowState = FormWindowState.Minimized; Close(); } private void exitToolStripMenuItem1_Click(object sender, EventArgs e) { //点击ContextMenu中的"Exit"事件 this.WindowState = FormWindowState.Minimized; Close(); }

----2005.12.15 10:26 星期四
文章来源:http://www.agilelabs.cn/blogs/woody/archive/2005/12/15/257.aspx