using System;using System.Windows.Forms; using System.Threading;using System.Drawing; namespace WindowsApplication9 { static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); NotifyIcon notifyIcon1 = new NotifyIcon(); ContextMenu contextMenu1 = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); contextMenu1.MenuItems.AddRange(new MenuItem[] { menuItem1 }); menuItem1.Index = 0; menuItem1.Text = "E&xit"; menuItem1.Click += new EventHandler(menuItem1_Click); notifyIcon1.Icon = new Icon("app.ico"); notifyIcon1.Text = "Form1 (NotifyIcon example)"; notifyIcon1.ContextMenu = contextMenu1; notifyIcon1.Visible = true; Application.Run(); notifyIcon1.Visible = false; } private static void menuItem1_Click(object Sender, EventArgs e) { Application.Exit(); } } }Reference: Notifyicon with contextmenu and no form
星期日, 11月 14, 2010
[C# WinForm]Notifyicon with contextmenu and no form
實作沒有表單的contextMenu
沒有留言:
張貼留言
留個話吧:)