[Repost] C # Writing a Windows application hidden in the task bar icon

xiaoxiao2021-03-06  49

1. Set the form property showintask = false2. Add the Notifyicon control Notifyicon1 to add an ICON icon to the property icon of the control Notifyicon1. 3. Add Form Minimization Event (First, you need to add event references): // this.sizechanged = new system.eventhandler (this.form1_sizechanged); // The above line is a reference to the main set inTIset () method private void Form1_SizeChanged (object sender, EventArgs e) {if (this.WindowState == FormWindowState.Minimized) {this.Hide (); this.notifyIcon1.Visible = true;}}. 4 click on the icon to add an event (event first need to add reference):. private void notifyIcon1_Click (object sender, EventArgs e) {this.Visible = true; this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = false;} 5 may be added to the context menu notifyIcon: main form Drake into a ContextMenu control ContextMenu1, point control, add menu in the context menu, and select ContextMenu1 as the context menu in the context menu. (You can add behavior in the submenu)

转载请注明原文地址:https://www.9cbs.com/read-40701.html

New Post(0)