1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2013 - Edijs Kolesnikovics
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "precomp.h"
22
23 TaskbarSettings g_TaskbarSettings;
24
Save()25 BOOL TaskbarSettings::Save()
26 {
27 SHSetValueW(hkExplorer, NULL, L"EnableAutotray", REG_DWORD, &bHideInactiveIcons, sizeof(bHideInactiveIcons));
28 SHSetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", REG_DWORD, &bPreferDate, sizeof(bPreferDate));
29 SHSetValueW(hkExplorer, L"Advanced", L"ShowSeconds", REG_DWORD, &bShowSeconds, sizeof(bShowSeconds));
30 SHSetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", REG_DWORD, &bGroupButtons, sizeof(bGroupButtons));
31 BOOL bAllowSizeMove = !bLock;
32 SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove));
33 sr.cbSize = sizeof(sr);
34 SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSmallIcons", REG_DWORD, &bSmallIcons, sizeof(bSmallIcons));
35 SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSd", REG_DWORD, &bShowDesktopButton, sizeof(bShowDesktopButton));
36 SHSetValueW(hkExplorer, L"StuckRects2", L"Settings", REG_BINARY, &sr, sizeof(sr));
37
38 /* TODO: AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */
39 return TRUE;
40 }
41
Load()42 BOOL TaskbarSettings::Load()
43 {
44 DWORD dwRet, cbSize, dwValue = NULL;
45
46 cbSize = sizeof(dwValue);
47 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", NULL, &dwValue, &cbSize);
48 bLock = (dwRet == ERROR_SUCCESS) ? (dwValue == 0) : TRUE;
49
50 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", NULL, &dwValue, &cbSize);
51 bPreferDate = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; /* This is opt-in setting */
52
53 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"ShowSeconds", NULL, &dwValue, &cbSize);
54 bShowSeconds = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;
55
56 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", NULL, &dwValue, &cbSize);
57 bGroupButtons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;
58
59 dwRet = SHGetValueW(hkExplorer, NULL, L"EnableAutotray", NULL, &dwValue, &cbSize);
60 bHideInactiveIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;
61
62 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSmallIcons", NULL, &dwValue, &cbSize);
63 bSmallIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : TRUE;
64
65 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"CompactTrayIcons", NULL, &dwValue, &cbSize);
66 if (dwRet == ERROR_SUCCESS && dwValue <= TIM_Max)
67 eCompactTrayIcons = static_cast<TrayIconsMode>(dwValue);
68 else
69 eCompactTrayIcons = TIM_Default;
70
71 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSd", NULL, &dwValue, &cbSize);
72 bShowDesktopButton = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : TRUE;
73
74 cbSize = sizeof(sr);
75 dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize);
76
77 /* Make sure we have correct values here */
78 if (dwRet != ERROR_SUCCESS || sr.cbSize != sizeof(sr) || cbSize != sizeof(sr))
79 {
80 sr.Position = ABE_BOTTOM;
81 sr.AutoHide = FALSE;
82 sr.AlwaysOnTop = TRUE;
83 sr.SmSmallIcons = FALSE;
84 sr.HideClock = FALSE;
85 sr.Rect.left = sr.Rect.top = 0;
86 sr.Rect.bottom = sr.Rect.right = 1;
87 sr.Size.cx = sr.Size.cy = 0;
88 }
89 else
90 {
91 if (sr.Position > ABE_BOTTOM)
92 sr.Position = ABE_BOTTOM;
93 }
94
95 return TRUE;
96 }
97
98 /* EOF */
99