C # use Windows API to hide/display the taskbar (findjavaswex, showwindow, findwindow)

Source: Internet
Author: User

Address: http://www.zu14.cn/2009/03/13/csharp-show-hide-taskbar-by-api/

Here, I will publish a method to display and hide Windows taskbar using Windows API. The Windows taskbar is actually a window, as long as I find the handle of this window, it is easy to show and hide. the taskbar is a window without a title, but the class name isShell_traywndTherefore, you can use findwindow or findwindowex to find its handle, and show and hide the window, using showwindow:

    • Introduction of Windows API Declaration
 
[Dllimport("User32.dll", Entrypoint ="Finddomainwex", Setlasterror =True)]
 
Static externIntptrFinddomainwex (IntptrHwndparent,IntptrHwndchildafter,StringLpszclass,StringLpszwindow );
 
 
[Dllimport("User32.dll", Entrypoint ="Showwindow", Setlasterror =True)]
 
Static extern boolShowwindow (IntptrHwnd,UintNcmdshow );

    • Display/hide the taskbar window
 
//IntptrTrayhwnd = find1_wex (Intptr. Zero,Intptr. Zero,"Shell_traywnd",Null);
 
IntptrTrayhwnd = findwindow ("Shell_traywnd",Null);
If(Trayhwnd! =Intptr. Zero)
 
{
 
Showwindow (trayhwnd, 0 );
 
}

The aboveCode, The second parameter of showwindow,1Display,0Hide

Address: http://www.zu14.cn/2009/03/13/csharp-show-hide-taskbar-by-api/

Here, I will publish a method to display and hide Windows taskbar using Windows API. The Windows taskbar is actually a window, as long as I find the handle of this window, it is easy to show and hide. the taskbar is a window without a title, but the class name isShell_traywndTherefore, you can use findwindow or findwindowex to find its handle, and show and hide the window, using showwindow:

    • Introduction of Windows API Declaration
[Dllimport("User32.dll", Entrypoint ="Finddomainwex", Setlasterror =True)]
 
Static externIntptrFinddomainwex (IntptrHwndparent,IntptrHwndchildafter,StringLpszclass,StringLpszwindow );
 
 
 
[Dllimport("User32.dll", Entrypoint ="Showwindow", Setlasterror =True)]
Static extern boolShowwindow (IntptrHwnd,UintNcmdshow );

    • Display/hide the taskbar window
 
//IntptrTrayhwnd = find1_wex (Intptr. Zero,Intptr. Zero,"Shell_traywnd",Null);
 
IntptrTrayhwnd = findwindow ("Shell_traywnd",Null);
 
If(Trayhwnd! =Intptr. Zero)
 
{
 
Showwindow (trayhwnd, 0 );
 
}

in the above Code, the second parameter of showwindow, 1 indicates display, and 0 indicates hiding

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.