Re: How to set the taskbar to auto-hide in the application? by Tom
Tom
Thu Oct 27 23:04:02 CDT 2005
You first need to set the registry entry that tells the shell to auto hide
the taskbar. That registry value is the unnamed value for the key
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\AutoHide]. This DWORD is
normally zero when auto hide is turned off. You need to set it to a
non-zero to turn auto hide on.
That alone, however, won't have an immediate effect on the taskbar. You'll
need to send it a message to tell it you've changed the setting. This is
done with the WM_SETTINGCHANGE message, with 0 and 5000 for wParam and
lParam respectively. Here's a short app that does all this:
#include "stdafx.h"
wchar_t * szAutoHideName = L"Software\\Microsoft\\Shell\\AutoHide";
void SetAutoHide(DWORD dwAutoHide);
int _tmain(int argc, TCHAR *argv[], TCHAR *envp[])
{
HWND hWndTB = FindWindow( L"HHTaskBar", NULL);
if (hWndTB != NULL)
{
SetAutoHide(TRUE);
SendMessage(hWndTB, WM_SETTINGCHANGE, 0, 5000);
}
return 0;
}
void SetAutoHide(DWORD dwAutoHide)
{
LONG lRet;
HKEY hkey;
DWORD dw;
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szAutoHideName,
0, KEY_ALL_ACCESS, &hkey);
if (lRet != ERROR_SUCCESS)
{
lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szAutoHideName, 0, NULL,
0,
KEY_ALL_ACCESS, NULL, &hkey, &dw);
}
if (lRet == ERROR_SUCCESS)
{
RegSetValueEx(hkey, L"", 0, REG_DWORD, (LPBYTE)&dwAutoHide,
sizeof(DWORD));
RegCloseKey(hkey);
}
}
Tom Gensel (eMVP)