C # The program is displayed as an icon in the lower right corner of the taskbar

Source: Internet
Author: User

C # The program is displayed as an icon in the lower right corner of the taskbar

Form minimization means that the entire form is reduced to the taskbar, but is displayed in the form of Form title bar,
To display the form in the lower-right corner of the taskbar as an icon, you must add a policyicon control to the form,
In the code that minimizes the form, you need to make the following changes:

If (this. windowstate = formwindowstate. normal & this. visible = true) {This. policyicon1.visible = true; // display form icon this in the notification area. windowstate = formwindowstate. minimized; this. visible = false; this. showintaskbar = false; // make the form not displayed on the taskbar}

In C #, display the minimize icon of the winform application on the taskbar and provide a right-click menu]

Minimize the winform window to the system tray, right-click the tray icon, and the exit menu is displayed.

 

1. Add the policyicon control myicon to the form, add an icon to the control's property icon, and text is the tip displayed when the mouse is on the icon.

2. Set the showintaskbar attribute of form in formateformclosing.

3. Set the showintaskbar and windowstate attributes of form in the myicon_mouseclick event.

4. Add the contextmenustrip control mymenu, right-click the tray icon to bring up the menu, and set the contextmenustrip attribute of myicon to mymenu. Add an item to mymenu (exit ).

5. In the mouseclick event, select right-click and pop up contextmenustrip.

Code:

Private void form=formclosing (Object sender, formclosingeventargs e) {If (E. closereason = closereason. userclosing) // {e. cancel = true; this. showintaskbar = false; this. myicon. icon = This. icon; this. hide () ;}} private void myicon_mouseclick (Object sender, mouseeventargs e) {If (E. button = mousebuttons. right) {mymenu. show ();} If (E. button = mousebuttons. left) {This. visible = true; this. windowstate = formwindowstate. normal;} private void toolmenucancel_click (Object sender, eventargs e) {application. exit ();}

  

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.