C # simple code to minimize forms to run on pallets

Source: Internet
Author: User

When you click the Minimize button, the program is scaled to the system tray. When you double-click the system tray icon, the program is restored.

1. Create a winform project. Other operations are skipped.

2. Pull a policyicon control, set the property visable to false, and enter some files on the text property.

3. Implement the form sizechanged event. The Code is as follows:

 

If (this. windowstate = formwindowstate. Minimized) // determines whether to minimize
{
This. showintaskbar = false; // It is not displayed in the system taskbar.
Policyicon. Visible = true; // The tray icon is visible.
}

 

4. Implement the DoubleClick event of the policyicon control. The Code is as follows:

If (this. windowstate = formwindowstate. Minimized)
{
This. showintaskbar = true; // displayed on the system taskbar
This. windowstate = formwindowstate. Normal; // restore the form
Policyicon. Visible = false; // hide the tray icon
}

 

Other automatically generated code blocks
Public form1 ()
{
Initializecomponent ();
This. sizechanged + = new eventhandler (mainform_sizechanged );
This. policyicon1.doubleclick + = new eventhandler (policyicon#doubleclick );
}

Article to learn it Network: http://www.xueit.com/html/2011-12/103-21394779782011124200715470.html

Related Article

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.