如何让C#写的应用程序最小化时显示在右下角的任务栏中?就像金山词霸那样。

解决方案 »

  1.   

    Creating the System Tray Icon
    Creating the system tray icon is pretty simple. The .NET Framework provides the NotifyIcon class. From the designer, all you need to do is drag a NotifyIcon control to the form. You may also want to design a custom icon to go with it.
      

  2.   

    用这个两个空件
     NotifyIcon  
     ContextMenu  
    并将窗体 NotifyIcon的属性   ContextMenu 设置成 this.SystemIconMenu 大概是这样
      

  3.   

    1 请看以下的介绍
    2 或者看看:http://www.codeguru.com/Csharp/.NET/net_general/tipstricks/article.php/c6933/
    Using the NotifyIcon control
    AuthorColin Harman MACITPDrag the NotifyIcon control onto your form from the toolbox. Now to initialize the notify icon, the code is pretty simple it goes like this.//SET THE BASICS UP 
    notifyIcon1.Icon = new System.Drawing.Icon (@"c:\1.ico"); 
    notifyIcon1.Visible = true; 
    notifyIcon1.Text = "Test Notify Icon Demo"; You can set the above properties in design time aswell by using the properties window, to hide the notifyIcon you need to set the notifyIcon1.visible = false. You can add click and double click events to the icon by simply inserting this code into the private void InitializeComponent() part of the form: this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); You can now use the below code to show the double click on the icon: private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) 

        MessageBox.Show("Icon Notify Double Clicked"); 
    } Now you will probably say great I can change the icon when an event happens in the program and I can see when the user has clicked on the icon to fire other events but how can i add a menu to the icon? Well its pretty simple you can use the ContextMenu control. As before drag and drop this control from the toolbox onto the form, a white container will appear at the top of the active form from where you can enter the menu items. To add this ContextMenu to the NotifyIcon you code it like notifyIcon1.ContextMenu = contextMenu1; The ContextMenu events work as they do with any other function calling the ContextMenu, by this i mean you create a event hander: this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); and then code the click like this: private void menuItem2_Click(object sender, System.EventArgs e) 

        MessageBox.Show("MenuItem2 Clicked"); 
    }
     I am 23 and live in west Sussex. I enjoy drinking, clubbing and going out, but I also enjoy writing programs + creating websites in my free time. I play golf and go skiing but skiing is tricky in this country. One of my main intrests when not drinking ;) is programming , the tv can get boring as hell, i first started programming with HTML in 1996 ish and in early 1998 i started learning Visual Basic, i am now learning C#.NET frm Jan 2004. I have continued to learn and gain valuable knowledge from the vb diploma i have completed. While learning vb i became a member of this here Developerfusion.com which i have now become a Moderator at. I try to give back what i have learnt. Examples of my previous projects like WebEdit and EasyCSS can be found on my website. 
      

  4.   

    寫那麼多干嘛!
    這個就可以啦!
    NotifyIcon