VC implementation Display, auto-hide taskbar (shappbarmessage)
First, show and hide the taskbar
To work on the taskbar, of course, you need to get a handle to the taskbar, so first use FindWindow to get a handle, and then manipulate
Example code:
1. Hide taskbar
HWND hwnd = FindWindow (_t ("Shell_traywnd"), NULL);
ShowWindow (Hwnd,sw_hide);
2. Show taskbar
HWND hwnd = FindWindow (_t ("Shell_traywnd"), NULL);
ShowWindow (hwnd,sw_show);
Second, automatically hide the taskbar and suppress the auto-hide taskbar (hidden in the auto-hide different)
Need to take advantage of an API function: SHAppBarMessage
Uint_ptr SHAppBarMessage (
DWORD Dwmessage,
Pappbardata PData
);
Parameter description:
Dwmessage can be the following parameters
Abm_activate activating a AppBar
Abm_getautohidebar retrieving the AppBar of the screen edge
Abm_getstate retrieving the top-level Microsoft Windows taskbar
Abm_gettaskbarpos Retrieving the taskbar
Abm_new register a new AppBar, the system sends a message to AppBar
Abm_querypos appbar size and screen position
Abm_remove unregister a appbar and move out of the system internal list
Abm_setautohidebar registering or canceling registration at the edge of the screen AppBar
Abm_setpos Setting the size and screen position of the AppBar
Abm_setstate setting AppBar to the top level
Abm_windowposchanged sends a message to the system when the AppBar state sends a change
PData
A appbardata structural body
Example code:
void Autohidetaskbar (BOOL bhide)
{
These three sentences are subject to circumstances
#ifndef abm_setstate
#define ABM_SETSTATE 0x0000000a
#endif
LPARAM LPARAM;
if (Bhide = = TRUE)
{
LParam = abs_autohide;//Auto-Hide
}
Else
{
LParam = abs_alwaysontop;//Suppress auto-hide
}
Appbardata Apbar;
memset (&apbar,0,sizeof (Apbar));
apbar.cbsize = sizeof (Apbar);
Apbar.hwnd = FindWindow ("Shell_traywnd", NULL);
if (Apbar.hwnd! = NULL)
{
Apbar.lparam = LParam;
SHAppBarMessage (Abm_setstate,&apbar); setting taskbar auto-Hide
}
}
Call Autohidetaskbar (TRUE);//or
Autohidetaskbar (FALSE);//