C # NotifyIcon Add system Tray

Source: Internet
Author: User

Requirements:

1 when the program starts, no system tray

2 when the program is minimized, the tray is displayed and the program is hidden

3 double-click System Tray, show main interface, tray hide

4 system Tray Right click on the Show and Exit button, main program display and exit

Code

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing;    Using system.linq;using system.text;using system.windows.forms;namespace systemicon{public partial class Form1:form        {public Form1 () {InitializeComponent (); } private void Form1_Load (object sender, EventArgs e) {} private void Form1_Resize (object sen Der, EventArgs e) {if (this.                WindowState = = formwindowstate.minimized) {//Minimize display of system tray, main interface hidden notifyicon1.visible = true; This.            Visible = false;            } else {//hide system tray Notifyicon1.visible = false; }} private void Notifyicon1_doubleclick (object sender, EventArgs e) {this. Visible = true; Displays the main window this.            WindowState = Formwindowstate.normal; This. Activate ();//Get Focus NOTIFYICON1.Visible = false;//Hidden tray} private void display Toolstripmenuitem_click (object sender, EventArgs e) {        Show main program Notifyicon1_doubleclick (sender, E); private void Exits Toolstripmenuitem_click (object sender, EventArgs e) {//exits this.            Close ();        Application.exit (); }    }}

Description

1 adding NotifyIcon and ContextMenuStrip

2 Using the NotifyIcon ContextMenuStrip Property Association ContextMenuStrip



C # NotifyIcon Add system Tray

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.