zoukankan      html  css  js  c++  java
  • WinForm程序设计系统托盘NotifyIcon控件右键菜单

    NotifyIcon控件
    (1)新创建一个项目,修改Form1的Text属性为testNotifyIcon;
    (2)向Form1窗口中添加一个NotifyIcon控件,修改其Name属性为 MyNotifyIcon。修改其Text属性为
       testNotifyIcon,与应用程序的标题相同。这是因为NotifyIcon显示在系统托盘中时,Text属性中保存的
       文本为鼠标移动到程序图标上时的提示信息。修改Icon属性,为NotifyIcon添加一个图标;
    (3)在Form1的属性窗口上,把Icon属性也选择为与NotifyIcon相同的图标。修改ShowInTaskBar属性值为
        False,这样,应用程序在运行时就不会出现在任务栏中;
    (4)添加双击NotifyIcon时的事件处理代码(DoubleClick)
       private void MynotifyIcon_DoubleClick(object sender, System.EventArgs e)
       { 
         if(this.Visible) 
          { 
            this.Hide(); 
          }else
               {
                 this.Show();
               }
          }
    (5)在使用NotifyIcon控件时,经常需要用到快捷菜单(ContextMenu控件),在NotifyIcon的ContextMenu属性中
       选择一个快捷菜单。这样在图标上可以通过快捷菜单执行程序的各种功能。   
    例如:给快捷菜单添加两个功能,一个为显示表单,一个为隐藏表单
    在功能的单击事件中代码如下:
    private void menuItem1_Click(object sender, System.EventArgs e)
       {
         this.Show();//显示表单
       }
       private void menuItem2_Click(object sender, System.EventArgs e)
       {
         this.Hide();//隐藏表单
       }
  • 相关阅读:
    学习自建调试体系(二)
    寻找未导出函数的函数地址
    Http
    git忽略.gitignore
    Flask-sqlacodegen
    liunx速查
    BBS论坛项目
    vim操作
    部署
    python3 环境搭建
  • 原文地址:https://www.cnblogs.com/puzi0315/p/2604060.html
Copyright © 2011-2022 走看看