C # how to hide and display the taskbar

Source: Internet
Author: User

1. Import the System. Runtime. InteropServices namespace.

2. The ShowWindow () API function can control the real state of a person and a form. Its declaration format is as follows:

Copy codeThe Code is as follows: [DllImport ("user32.dll")]
Public static extern int ShowWindow (int hwnd, int nCmdShow );

Hwnd indicates the handle of the form, and nCmdShow indicates the actual state of the form.

3. the API function FindWindow () can be used to return the "Shell_TrayWnd" handle of the Form class in the taskbar. The declaration format is as follows:

Copy codeThe Code is as follows: [DllImport ("user32.dll")]
Public static extern int FindWindow (string lpClassName, string lpWindowName );

The example is as follows. The main code is (two btn controls are used ):Copy codeThe Code is as follows: private const int SW_HIDE = 0; // hide the taskbar
Private const int SW_RESTORE = 9; // display the taskbar

[DllImport ("user32.dll")]
Public static extern int ShowWindow (int hwnd, int nCmdShow );
[DllImport ("user32.dll")]
Public static extern int FindWindow (string lpClassName, string lpWindowName );

Private void button#click (object sender, EventArgs e)
{
ShowWindow (FindWindow ("Shell_TrayWnd", null), SW_HIDE );
// YinYiNiao's Blog
}

Private void button2_Click (object sender, EventArgs e)
{

ShowWindow (FindWindow ("Shell_TrayWnd", null), SW_RESTORE );
}

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.