C # Hide/Display Windows taskbar

Source: Internet
Author: User

The Windows taskbar is actually a form without a title, so you only need to find this form to hide and display it.

[Dllimport ("user32.dll", entrypoint = "find?wex", setlasterror = true)] <br/> static extern intptr values (intptr hwndparent, intptr values, string lpszclass, string lpszwindow ); </P> <p> [dllimport ("user32.dll", entrypoint = "showwindow", setlasterror = true)] <br/> static extern bool showwindow (intptr hwnd, uint ncmdshow); </P> <p> private void button#click (Object sender, eventargs E) <br/>{< br/> intptr trayhwnd = find1_wex (intptr. zero, intptr. zero, "shell_traywnd", null); // find the first subwindow that matches the specified condition in the window list, if no value is found, 0 is returned. <br/> // intptr trayhwnd = findwindow ("shell_traywnd", null); // you can find the first top-level window in the window list that meets the specified conditions, use the API function getwindowtext to obtain the name of the window <br/>/* hwnd <br/> the handle of the window to change the show status. <br/> ncmdshow <br/> exactly one of the following flags specifying how to show the wi Ndow: </P> <p> sw_hide = 0 <br/> hide the window. <br/> sw_maximize = 3 <br/> maximize the window. <br/> sw_minimize = 6 <br/> minimize the window. <br/> sw_restore = 9 <br/> restore the window (not maximized nor minimized ). <br/> sw_show = 5 <br/> show the window. <br/> sw_showmaximized = 3 <br/> show the window maximized. <br/> sw_showminimized = 2 <br/> show the window minimized. <br/> sw_showminnoactive = 7 <B R/> show the window minimized but do not activate it. <br/> sw_showna = 8 <br/> show the window in its current state but do not activate it. <br/> sw_shownoactivate = 4 <br/> show the window in its most recent size and position but do not activate it. <br/> sw_shownormal = 1 <br/> show the window and activate it (as usual ). */<br/> If (button1.text = "hide") <br/>{< br/> If (trayhwnd! = Intptr. zero) <br/>{< br/> showwindow (trayhwnd, 0); <br/> button1.text = "show "; <br/>}</P> <p >}< br/> else <br/>{< br/> showwindow (trayhwnd, 1 ); <br/> button1.text = "hide"; <br/>}< br/>}

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.