C # Write the WINDOW APPLLICTION hidden as a taskbar icon

xiaoxiao2021-03-06  62

1. Set the form attribute showintask = false

2. Add a Notifyicon Control Notifyicon1 to add an ICON icon to the property Icon's property icon of the control NOTIFYICON1.

3. Add a form minimize events (first you need to add event references):

// this.sizechanged = new system.eventhandler (this.form1_sizechange;

// The above line is a reference to the main form initializeComponent () method.

Private void form1_sizechanged (object sender, eventargs e) {if (this.windowstate == formwindowstate.minimized) {this.hide (); this.notifyicon1.visible = true;}

} 4. Add click icon event (first you need to add an event reference):

Private void notifyicon1_click (object sender, evenetargs e) {this.visible = true;

THIS.WINDOWSTATE = FormWindowState.Normal;

THISIBLE = false;

5. You can add the right-click menu for Notifyicon:

The main form is dragged into a ContextMenu control ContextMenu1, point control, add menu in the context menu, and select ContextMenu1 as the context menu in the context menu.

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

New Post(0)