C # writes a window appllication that is hidden as a taskbar icon when it is minimized.

Source: Internet
Author: User
Windows C # writes a window appllication that is hidden as a taskbar icon when it is minimized.
1. Set WinForm Form Properties Showintask=false

2. Add the NotifyIcon control NotifyIcon1, adding an icon icon for the property icon of the control NotifyIcon1.

3. Add form Minimize event (you need to add an event reference first):

This. SizeChanged + = new System.EventHandler (this. form1_sizechanged);

The above line is the reference that needs to be added in 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 need to add event reference):

private void Notifyicon1_click (object sender, EventArgs e)
{
This. Visible = true;

This. WindowState = Formwindowstate.normal;

This.notifyIcon1.Visible = false;
}


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.