C # automatically hide and display the taskbar of the Control System

Source: Internet
Author: User

Public struct rect
{
Public int left;
Public int
Top;
Public int right;
Public int bottom;
}

Public struct appbardata
{
Public int cbsize;

Public int hwnd;
Public int ucallbackmessage;
Public int
Uedge;
Public rect RC;
Public int lparam;
}

Public const int abs_alwaysontop = 0x002;
Public const int
Abs_autohide = 0x001;
Public const int abs_both = 0x003;

Public const int abm_activate = 0x006;
Public const int abm_getstate
= 0x004;
Public const int abm_gettaskbarpos = 0x005;

Public const int abm_new = 0x000;
Public const int abm_querypos =
0x002;
Public const int abm_setautohidebar = 0x008;
Public
Const int abm_setstate = 0x00a;

///
/// Send a message to the system taskbar
///

[Dllimport ("shell32.dll")]
Public static extern
Int shappbarmessage (INT dwmsg, ref appbardata APP );

[Dllimport ("user32.dll", entrypoint = "findwindow")]

Public static extern int findwindow (string lpclassname, string
Lpwindowname );

///
/// Set whether the system taskbar is automatically hidden
///

///

True is set to Auto Hide, false
Cancel Auto Hide
Public static void setappbarautodisplay (bool
Isauto)
{
Appbardata Abd = new
Appbardata ();
Abd. hwnd = findwindow ("shell_traywnd ",
"");
// Abd. lparam = abs_alwaysontop or abs_autohide
'Automatically hidden and located before the window
// Abd. lparam = abs_alwaysontop
'It is not automatically hidden and is located before the window
// Abd. lparam = abs_autohide
'Automatically hidden, not in front of the window
If (isauto)
{

Abd. lparam = abs_autohide;
Shappbarmessage (abm_setstate, ref
Abd );
}
Else
{

Abd. lparam = abs_alwaysontop;
Shappbarmessage (abm_setstate,
Ref Abd );
}
}

 

Pass the test in XP and 2003 systems!

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.