C # Write the Window Appll that is hidden as a taskbar icon when minimizing minimization.

xiaoxiao2021-03-06  82

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.

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 events (first you need to add event references):

?? private void notifyicon1_click (Object sender, eventargs e) ?? {??? this.visible = true;

??? this.windowstate = formwindowstate.normal;

??? this.notifyicon1.visible = 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.

(You can add behavior in the submenu)

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

New Post(0)