有关NotifyIcon的使用

NotifyIcon可以在指定在状态区域创建一个图标,为了使用该控件,可执行以下步骤:
1、在窗体上拖放一个NotifyIcon控件
2、设置NotifyIcon的Icon和Text属性,Icon指定状态栏显示的图标,Text用于显示一个ToolTip
3、在窗体中加入如下代码
 1 ExpandedBlockStart.gif ContractedBlock.gif Notify Icon code for icon in windows status bar area #Region "Notify Icon code for icon in windows status bar area"
 2ExpandedSubBlockStart.gifContractedSubBlock.gif    Private Sub MainForm_Deactivate()Sub MainForm_Deactivate(ByVal sender As ObjectByVal e As System.EventArgs) Handles MyBase.Deactivate
 3InBlock.gif
 4InBlock.gif        ' This will force the NotifyIcon to work
 5InBlock.gif        If Me.WindowState = FormWindowState.Minimized Then
 6InBlock.gif            Me.Visible = False
 7InBlock.gif        End If
 8InBlock.gif
 9ExpandedSubBlockEnd.gif    End Sub

10InBlock.gif
11InBlock.gif    Dim preState As Integer
12ExpandedSubBlockStart.gifContractedSubBlock.gif    Private Sub MainForm_Resize()Sub MainForm_Resize(ByVal sender As ObjectByVal e As System.EventArgs) Handles MyBase.Resize
13InBlock.gif        '记住窗体最小化前的状态,以便在单击窗体时恢复到最小化前的状态
14InBlock.gif        If Me.WindowState <> FormWindowState.Minimized Then
15InBlock.gif            preState = Me.WindowState
16InBlock.gif        End If
17ExpandedSubBlockEnd.gif    End Sub

18InBlock.gif
19ExpandedSubBlockStart.gifContractedSubBlock.gif    Private Sub NotifyIcon1_Click()Sub NotifyIcon1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles NotifyIcon1.Click
20InBlock.gif
21InBlock.gif        ' set the application back to it's normal state from the 
22InBlock.gif        ' notify icon on the status bar of Windows
23InBlock.gif        Me.Cursor = Cursors.AppStarting
24InBlock.gif        If Me.Visible = False Then
25InBlock.gif            Me.Visible = True
26InBlock.gif        Else
27InBlock.gif            Me.Visible = False
28InBlock.gif        End If
29InBlock.gif
30InBlock.gif        If Me.WindowState = FormWindowState.Minimized Then
31InBlock.gif            Me.WindowState = preState 'FormWindowState.Normal
32InBlock.gif        Else
33InBlock.gif            Me.WindowState = FormWindowState.Minimized
34InBlock.gif        End If
35InBlock.gif        Me.Cursor = Cursors.Default
36ExpandedSubBlockEnd.gif    End Sub

37InBlock.gif
38ExpandedBlockEnd.gif#End Region

转载于:https://www.cnblogs.com/chinapro/archive/2005/05/07/150343.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值