From a0360cc9e830da3cc6df576bfc845cd35b3240a7 Mon Sep 17 00:00:00 2001 From: Robert Naumann Date: Mon, 8 May 2017 15:27:33 +0000 Subject: [PATCH 1/1] [EXPLORER] - Load and save "Lock Taskbar", "Hide inactive icons", and "Group similar taskbar buttons". Verified on Win2k3 via "Nirsoft RegFromApp". - use a loader function for registry values. - save the "show seconds" setting together with the other explorer settings instead of a ROS specific key. - Add some documentation comments. svn path=/trunk/; revision=74500 --- reactos/base/shell/explorer/precomp.h | 4 ++ reactos/base/shell/explorer/settings.cpp | 68 ++++++++++++++++-------- reactos/base/shell/explorer/trayprop.cpp | 7 +++ 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/reactos/base/shell/explorer/precomp.h b/reactos/base/shell/explorer/precomp.h index 00c923e40de..fc5d23d9b73 100644 --- a/reactos/base/shell/explorer/precomp.h +++ b/reactos/base/shell/explorer/precomp.h @@ -199,6 +199,10 @@ LoadTaskBarSettings(VOID); VOID SaveTaskBarSettings(VOID); +BOOL +LoadSettingDword(IN LPCWSTR pszKeyName, + IN LPCWSTR pszValueName, + OUT DWORD &dwValue); BOOL SaveSettingDword(IN LPCWSTR pszKeyName, IN LPCWSTR pszValueName, diff --git a/reactos/base/shell/explorer/settings.cpp b/reactos/base/shell/explorer/settings.cpp index de7540655ef..2b881773014 100644 --- a/reactos/base/shell/explorer/settings.cpp +++ b/reactos/base/shell/explorer/settings.cpp @@ -21,40 +21,66 @@ #include "precomp.h" TASKBAR_SETTINGS TaskBarSettings; -const WCHAR szAdvancedSettingsKey[] = L"Software\\ReactOS\\Features\\Explorer"; +const WCHAR szSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"; +const WCHAR szAdvancedSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"; VOID LoadTaskBarSettings(VOID) { - HKEY hKey; - - /* Set defaults */ - TaskBarSettings.bLock = TRUE; + DWORD dwValue = NULL; + + LoadSettingDword(szAdvancedSettingsKey, TEXT("TaskbarSizeMove"), dwValue); + TaskBarSettings.bLock = (dwValue != 0) ? TRUE : FALSE; + + LoadSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), dwValue); + TaskBarSettings.bShowSeconds = (dwValue != 0) ? TRUE : FALSE; + + LoadSettingDword(szSettingsKey, TEXT("EnableAutotray"), dwValue); + TaskBarSettings.bHideInactiveIcons = TRUE; + + LoadSettingDword(szAdvancedSettingsKey, TEXT("TaskbarGlomming"), dwValue); + TaskBarSettings.bGroupButtons = (dwValue != 0) ? TRUE : FALSE; + + TaskBarSettings.bShowQuickLaunch = TRUE; //FIXME: Where is this stored, and how? + + /* FIXME: The following settings are stored in stuckrects2, do they have to be load here too? */ + TaskBarSettings.bShowClock = TRUE; TaskBarSettings.bAutoHide = FALSE; TaskBarSettings.bAlwaysOnTop = FALSE; - TaskBarSettings.bGroupButtons = TRUE; - TaskBarSettings.bShowQuickLaunch = TRUE; - TaskBarSettings.bShowClock = TRUE; - TaskBarSettings.bShowSeconds = FALSE; - TaskBarSettings.bHideInactiveIcons = TRUE; - - /* Check registry */ - if (RegOpenKeyW(HKEY_CURRENT_USER, szAdvancedSettingsKey, &hKey) == ERROR_SUCCESS) - { - DWORD dwValue, dwValueLength, dwType; - dwValueLength = sizeof(dwValue); - if (RegQueryValueExW(hKey, L"ShowSeconds", NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD) - TaskBarSettings.bShowSeconds = dwValue != 0; - - RegCloseKey(hKey); - } } VOID SaveTaskBarSettings(VOID) { + SaveSettingDword(szAdvancedSettingsKey, TEXT("TaskbarSizeMove"), TaskBarSettings.bLock); SaveSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), TaskBarSettings.bShowSeconds); + SaveSettingDword(szSettingsKey, TEXT("EnableAutotray"), TaskBarSettings.bHideInactiveIcons); + SaveSettingDword(szAdvancedSettingsKey, TEXT("TaskbarGlomming"), TaskBarSettings.bGroupButtons); + + /* FIXME: Show Clock, AutoHide and Always on top are stored in the stuckrects2 key but are not written to it with a click on apply. How is this done instead? + AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */ +} + +BOOL +LoadSettingDword(IN LPCWSTR pszKeyName, + IN LPCWSTR pszValueName, + OUT DWORD &dwValue) +{ + BOOL ret = FALSE; + HKEY hKey; + + if (RegOpenKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS) + { + DWORD dwValueLength, dwType; + + dwValueLength = sizeof(dwValue); + ret = RegQueryValueExW(hKey, pszValueName, NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD; + + RegCloseKey(hKey); + } + + return ret; } BOOL diff --git a/reactos/base/shell/explorer/trayprop.cpp b/reactos/base/shell/explorer/trayprop.cpp index 960ed34d716..a53e7e600d7 100644 --- a/reactos/base/shell/explorer/trayprop.cpp +++ b/reactos/base/shell/explorer/trayprop.cpp @@ -319,7 +319,14 @@ TaskbarPageProc(HWND hwndDlg, break; case PSN_APPLY: + TaskBarSettings.bLock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_LOCK); + TaskBarSettings.bAutoHide = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDE); + TaskBarSettings.bAlwaysOnTop = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_ONTOP); + TaskBarSettings.bGroupButtons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_GROUP); + TaskBarSettings.bShowQuickLaunch = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SHOWQL); + TaskBarSettings.bShowClock = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_CLOCK); TaskBarSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS); + TaskBarSettings.bHideInactiveIcons = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_HIDEICONS); SaveTaskBarSettings(); break; } -- 2.17.1