使用菜单和子菜单创建系统托盘应用程序 [英] Creating a system tray app with menu and Sub Menu

查看:63
本文介绍了使用菜单和子菜单创建系统托盘应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是:



My Code is:

public ContextMenu traymenu;

public Form()
       {
           trayMenu = new ContextMenu();
           trayMenu.MenuItems.Add("Logout", OnExit);

           trayIcon = new NotifyIcon();
           trayIcon.Text = "KHorizon Chat";
           trayIcon.Icon = new System.Drawing.Icon(KHorizon_Chat.Properties.Resources.chat, 40, 40);

           trayIcon.ContextMenu = trayMenu;
           trayIcon.Visible = true;
           InitializeComponent();
       }
private void Form_Load(object sender, EventArgs e)
       {
           this.WindowState = FormWindowState.Minimized;
           this.Visible = false;
       }
private void OnExit(object sender, EventArgs e)
       {
           System.Environment.Exit(0);
       }





解决方案需求:

我需要将子菜单与子菜单一起显示?



solution need:
I need the contextmenu to be displayed with sub-menus?

推荐答案

请参考此链接:

http://progtuts.info/14/your-c-program-in-the-system-tray/ [ ^ ]
refer this link:
http://progtuts.info/14/your-c-program-in-the-system-tray/[^]


这篇关于使用菜单和子菜单创建系统托盘应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆