VC implementation Display, auto-hide taskbar (shappbarmessage)

Source: Internet
Author: User
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);//

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.