vs2005中NotifyIcon控件的使用

为了使用该控件,可执行以下步骤:
1、在窗体上拖放一个NotifyIcon控件
2、设置NotifyIcon的Icon和Text属性,Icon指定状态栏显示的图标,Text用于显示一个ToolTip
3、在窗体中加入如下代码

 1None.gif    public partial class Form1 : Form
 2ExpandedBlockStart.gifContractedBlock.gif    dot.gif{
 3InBlock.gif        FormWindowState preState;
 4InBlock.gif        public Form1()
 5ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 6InBlock.gif            InitializeComponent();
 7ExpandedSubBlockEnd.gif        }

 8InBlock.gif
 9InBlock.gif        private void Form1_Load(object sender, EventArgs e)
10ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
11InBlock.gif
12ExpandedSubBlockEnd.gif        }

13InBlock.gif
14InBlock.gif        private void Form1_Resize(object sender, EventArgs e) //窗体大小改变前保存窗体状态
15ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
16InBlock.gif            if (this.WindowState != FormWindowState.Minimized)
17ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
18InBlock.gif                preState = this.WindowState;
19ExpandedSubBlockEnd.gif            }

20ExpandedSubBlockEnd.gif        }

21InBlock.gif
22InBlock.gif        private void Form1_Deactivate(object sender, EventArgs e) //窗体不活动时的事件处理
23ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
24InBlock.gif            if (this.WindowState == FormWindowState.Minimized)
25InBlock.gif                this.Visible = false;
26ExpandedSubBlockEnd.gif        }

27InBlock.gif
28InBlock.gif        private void notifyIcon1_Click(object sender, EventArgs e)//notifyIcon的点击事件
29ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
30InBlock.gif            if (this.Visible)
31InBlock.gif                this.Visible = false;
32InBlock.gif            else
33InBlock.gif                this.Visible = true;
34InBlock.gif            if (this.WindowState == FormWindowState.Minimized)
35InBlock.gif                this.WindowState = preState;
36InBlock.gif            else
37InBlock.gif                this.WindowState = FormWindowState.Minimized;
38ExpandedSubBlockEnd.gif        }

39InBlock.gif
40ExpandedBlockEnd.gif    }

 

其他属性:
     1.BalloonTipIcon属性  用于选择提示窗口的类型。
     2.BalloonTipText属性  用于设置提示窗口的内容信息。
     3.BalloonTipTitle属性  用于设置提示窗口的标题信息。
     4.ConTextMenuStrip属性  用于添加右键点击时的菜单。
另需要调用ShowBalloonTip()方法才能显示提示窗口。



转载于:https://www.cnblogs.com/zmsx/archive/2005/12/05/291207.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值