ReactOS 0.4.16-dev-340-g0540c21
general.cpp
Go to the documentation of this file.
1/*
2 * 'General' tab property sheet of Folder Options
3 *
4 * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
5 * Copyright 2016-2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include "precomp.h"
23
25
27 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer";
28
30// Shell settings
31
32EXTERN_C void
34{
35 ZeroMemory(pss, sizeof(*pss));
36 pss->fShowAllObjects = TRUE;
37 pss->fShowExtensions = TRUE;
38 pss->fShowCompColor = TRUE;
40 pss->fShowAttribCol = TRUE; // ROS defaults to Details view with this column on
41 pss->fShowInfoTip = TRUE;
44 pss->iSortDirection = 1;
46 pss->fSepProcess = FALSE;
47 pss->fStartPanelOn = FALSE; // Note: This should be changed to TRUE when the modern start menu is implemented
48}
49
52{
56 REG_BINARY, prss, prss->dwSize);
57}
58
59// bDoubleClick is TRUE if "Double-click to open an item (single-click to select)".
60// bDoubleClick is FALSE if "Single-click to open an item (point to select)".
62// API Monitor:
63// SHLWAPI.dll RegOpenKeyExW ( 0x000000c8, NULL, 0, MAXIMUM_ALLOWED, 0x00def234 ) ERROR_SUCCESS 0.0000243
64// SHLWAPI.dll RegSetValueExW ( 0x000003e8, "ShellState", 0, REG_BINARY, 0x000c2050, 36 ) ERROR_SUCCESS 0.0001028
65// SHLWAPI.dll RegCloseKey ( 0x000003e8 ) ERROR_SUCCESS 0.0000081
66// Explorer.EXE SHSettingsChanged ( 0, "ShellState" ) 0.0000131
67static BOOL
68IntSetShellStateSettings(BOOL bDoubleClick, BOOL bUseCommonTasks)
69{
70 SHELLSTATE shellstate;
71 shellstate.fDoubleClickInWebView = !!bDoubleClick;
72 shellstate.fWebView = !!bUseCommonTasks;
74
75 SHSettingsChanged(0, L"ShellState");
76 return TRUE;
77}
78
80// API Monitor:
81// SHLWAPI.dll RegOpenKeyExW ( 0x000000c8, NULL, 0, MAXIMUM_ALLOWED, 0x0007e484 ) ERROR_SUCCESS 0.0000388
82// SHLWAPI.dll RegQueryValueExW ( 0x000005a8, "ShellState", NULL, 0x0007e474, 0x000c2050, 0x0007e4fc ) ERROR_SUCCESS 0.0000271
83// SHLWAPI.dll RegCloseKey ( 0x000005a8 ) ERROR_SUCCESS 0.0000112
86{
87 DWORD dwSize = sizeof(REGSHELLSTATE);
89 L"ShellState", NULL, prss, &dwSize);
90 return err == ERROR_SUCCESS && prss->dwSize >= REGSHELLSTATE_SIZE;
91}
92
93// bIconUnderline is TRUE if "Underline icon titles only when I point at them".
94// bIconUnderline is FALSE if "Underline icon titles consistent with my browser".
96// API Monitor:
97// SHELL32.dll SHRegGetUSValueW ( "Software\Microsoft\Windows\CurrentVersion\Explorer", "IconUnderline", NULL, 0x00d2f324, 0x00d2f328, FALSE, 0x00d2f32c, 4 ) ERROR_SUCCESS 0.0002484
98// SHELL32.dll IsDlgButtonChecked ( 0x0005009e, 30104 ) BST_CHECKED 0.0000212
99// SHELL32.dll SHRegSetUSValueW ( "Software\Microsoft\Windows\CurrentVersion\Explorer", "IconUnderline", 0, 0x00d2f314, 4, 6 ) ERROR_SUCCESS 0.0008300
100// Explorer.EXE SHSettingsChanged ( 0, "Software\Microsoft\Windows\CurrentVersion\Explorer\IconUnderline" ) 0.0000092
101static BOOL IntSetUnderlineState(BOOL bIconUnderline)
102{
104 DWORD dwValue = (bIconUnderline ? 3 : 2), dwSize = sizeof(DWORD);
107 if (Status != ERROR_SUCCESS)
108 return FALSE;
109
110 SHSettingsChanged(0, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\IconUnderline");
111 return TRUE;
112}
113
115{
116 DWORD dwValue, dwDefault = 2, dwSize = sizeof(DWORD);
117 SHRegGetUSValue(s_pszExplorerKey, L"IconUnderline", NULL, &dwValue, &dwSize, FALSE, &dwDefault, sizeof(DWORD));
118 return dwValue == 3;
119}
120
121// bNewWindowMode is TRUE if "Open each folder in its own window".
122// bNewWindowMode is FALSE if "Open each folder in the same window".
124// API Monitor:
125// SHELL32.dll RegCreateKeyExW ( HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState", 0, NULL, 0, KEY_SET_VALUE, NULL, 0x00d2f2b8, NULL ) ERROR_SUCCESS 0.0000455
126// SHELL32.dll RegSetValueExW ( 0x00000854, "Settings", 0, REG_BINARY, 0x0210f170, 12 ) ERROR_SUCCESS 0.0001472
127// SHELL32.dll RegSetValueExW ( 0x00000854, "FullPath", 0, REG_DWORD, 0x00d2f2ac, 4 ) ERROR_SUCCESS 0.0000168
128// SHELL32.dll RegCloseKey ( 0x00000854 ) ERROR_SUCCESS 0.0000000
129static HRESULT IntSetNewWindowMode(BOOL bNewWindowMode)
130{
132 if (!ReadCabinetState(&cs, sizeof(cs)))
133 return E_FAIL;
134
135 BOOL changed = !!cs.fNewWindowMode != !!bNewWindowMode;
136 cs.fNewWindowMode = !!bNewWindowMode;
137 return WriteCabinetState(&cs) ? (changed ? S_OK : S_FALSE) : E_FAIL;
138}
139
141{
143 if (!ReadCabinetState(&cs, sizeof(cs)))
144 return FALSE;
145
146 return !!cs.fNewWindowMode;
147}
148
150// GeneralDlg
151
152typedef struct GENERAL_DIALOG
153{
158
159static VOID
161{
162 HICON hTaskIcon = NULL, hFolderIcon = NULL, hClickIcon = NULL;
163 LPTSTR lpTaskIconName = NULL, lpFolderIconName = NULL, lpClickIconName = NULL;
164
165 // Show task setting icon.
170
171 if (lpTaskIconName)
172 {
173 hTaskIcon = (HICON)LoadImage(shell32_hInstance, lpTaskIconName,
175 if (hTaskIcon)
176 {
177 HWND hwndTaskIcon = GetDlgItem(hDlg, IDC_FOLDER_OPTIONS_TASKICON);
178 SendMessage(hwndTaskIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hTaskIcon);
179 }
180 }
181
182 // Show Folder setting icons
187
188 if (lpFolderIconName)
189 {
190 hFolderIcon = (HICON)LoadImage(shell32_hInstance, lpFolderIconName,
192 if (hFolderIcon)
193 {
194 HWND hwndFolderIcon = GetDlgItem(hDlg, IDC_FOLDER_OPTIONS_FOLDERICON);
195 SendMessage(hwndFolderIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hFolderIcon);
196 }
197 }
198
199 // Show click setting icon
204
205 if (lpClickIconName)
206 {
207 hClickIcon = (HICON)LoadImage(shell32_hInstance, lpClickIconName,
209 if (hClickIcon)
210 {
211 HWND hwndClickIcon = GetDlgItem(hDlg, IDC_FOLDER_OPTIONS_CLICKICON);
212 SendMessage(hwndClickIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hClickIcon);
213 }
214 }
215
216 // Replace icons
217 if (hTaskIcon)
218 {
219 DestroyIcon(pGeneral->hTaskIcon);
220 pGeneral->hTaskIcon = hTaskIcon;
221 }
222 if (hFolderIcon)
223 {
224 DestroyIcon(pGeneral->hFolderIcon);
225 pGeneral->hFolderIcon = hFolderIcon;
226 }
227 if (hClickIcon)
228 {
229 DestroyIcon(pGeneral->hClickIcon);
230 pGeneral->hClickIcon = hClickIcon;
231 }
232
233 if (nCtrlID == IDC_FOLDER_OPTIONS_SINGLECLICK)
234 {
237 }
238
239 if (nCtrlID == IDC_FOLDER_OPTIONS_DOUBLECLICK)
240 {
244 }
245}
246
247static void
248GeneralDlg_StoreToUI(HWND hwndDlg, BOOL bDoubleClick, BOOL bUseCommonTasks,
249 BOOL bUnderline, BOOL bNewWindowMode, PGENERAL_DIALOG pGeneral)
250{
251 EnableWindow(GetDlgItem(hwndDlg, IDC_FOLDER_OPTIONS_COMMONTASKS), bUseCommonTasks); // FIXME: ROS DefView does not support WebView nor the tasks pane
252
253 if (bUseCommonTasks)
255 else
257
258 if (bDoubleClick)
260 else
262
263 if (bNewWindowMode)
265 else
267
268 if (!bDoubleClick)
269 {
272 if (bUnderline)
274 else
276 }
277 else
278 {
282 }
283}
284
285static BOOL
287{
290 BOOL bDoubleClick = !!ss.fDoubleClickInWebView;
291 BOOL bUseCommonTasks = !!ss.fWebView;
292 BOOL bUnderline = IntGetUnderlineState();
293 BOOL bNewWindowMode = IntGetNewWindowMode();
294
295 GeneralDlg_StoreToUI(hwndDlg, bDoubleClick, bUseCommonTasks, bUnderline, bNewWindowMode, pGeneral);
296 GeneralDlg_UpdateIcons(hwndDlg, 0, pGeneral);
297
298 return TRUE;
299}
300
301static void
303{
304 // default values
305 BOOL bDoubleClick = TRUE;
306 BOOL bUseCommonTasks = TRUE;
307 BOOL bUnderline = FALSE;
308 BOOL bNewWindowMode = (_WIN32_WINNT < _WIN32_WINNT_WIN2K);
309
310 GeneralDlg_StoreToUI(hwndDlg, bDoubleClick, bUseCommonTasks, bUnderline, bNewWindowMode, pGeneral);
311 GeneralDlg_UpdateIcons(hwndDlg, 0, pGeneral);
312}
313
314static BOOL
316{
318 BOOL bUseCommonTasks = (IsDlgButtonChecked(hwndDlg, IDC_FOLDER_OPTIONS_COMMONTASKS) == BST_CHECKED);
320 BOOL bNewWindowMode = !(IsDlgButtonChecked(hwndDlg, IDC_FOLDER_OPTIONS_SAMEWINDOW) == BST_CHECKED);
321
322 IntSetUnderlineState(bUnderline);
323 BOOL updateCabinets = IntSetNewWindowMode(bNewWindowMode) == S_OK;
324 IntSetShellStateSettings(bDoubleClick, bUseCommonTasks);
325 if (updateCabinets)
327 return TRUE;
328}
329
332 HWND hwndDlg,
333 UINT uMsg,
336{
337 static GENERAL_DIALOG general;
338
339 switch (uMsg)
340 {
341 case WM_INITDIALOG:
342 general.hTaskIcon = NULL;
343 general.hFolderIcon = NULL;
344 general.hClickIcon = NULL;
345 return GeneralDlg_OnInitDialog(hwndDlg, &general);
346
347 case WM_COMMAND:
348 switch (LOWORD(wParam))
349 {
358 if (HIWORD(wParam) == BN_CLICKED)
359 {
360 GeneralDlg_UpdateIcons(hwndDlg, LOWORD(wParam), &general);
361
362 // Enable the 'Apply' button
363 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
364 }
365 break;
367 if (HIWORD(wParam) == BN_CLICKED)
368 {
369 GeneralDlg_OnRestoreDefaults(hwndDlg, &general);
370
371 // Enable the 'Apply' button
372 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
373 }
374 break;
375 }
376 break;
377
378 case WM_NOTIFY:
379 {
380 LPNMHDR pnmh = (LPNMHDR)lParam;
381
382 switch (pnmh->code)
383 {
384 case PSN_SETACTIVE:
385 break;
386
387 case PSN_APPLY:
388 return GeneralDlg_OnApply(hwndDlg, &general);
389 }
390 break;
391 }
392
393 case WM_DESTROY:
394 DestroyIcon(general.hTaskIcon);
395 DestroyIcon(general.hFolderIcon);
396 DestroyIcon(general.hClickIcon);
397 break;
398
399 default:
400 return FALSE;
401 }
402 return FALSE;
403}
#define shell32_hInstance
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define _WIN32_WINNT
Definition: precomp.h:14
#define EXTERN_C
Definition: basetyps.h:12
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
static BOOL IntGetNewWindowMode(VOID)
Definition: general.cpp:140
static BOOL IntGetUnderlineState(VOID)
Definition: general.cpp:114
static BOOL IntSetShellStateSettings(BOOL bDoubleClick, BOOL bUseCommonTasks)
Definition: general.cpp:68
static BOOL IntSetUnderlineState(BOOL bIconUnderline)
Definition: general.cpp:101
static BOOL GeneralDlg_OnInitDialog(HWND hwndDlg, PGENERAL_DIALOG pGeneral)
Definition: general.cpp:286
struct GENERAL_DIALOG * PGENERAL_DIALOG
static const LPCWSTR s_pszExplorerKey
Definition: general.cpp:26
static HRESULT IntSetNewWindowMode(BOOL bNewWindowMode)
Definition: general.cpp:129
EXTERN_C BOOL SHELL32_ReadRegShellState(PREGSHELLSTATE prss)
Definition: general.cpp:85
static VOID GeneralDlg_UpdateIcons(HWND hDlg, UINT nCtrlID, PGENERAL_DIALOG pGeneral)
Definition: general.cpp:160
EXTERN_C void SHELL32_GetDefaultShellState(LPSHELLSTATE pss)
Definition: general.cpp:33
static void GeneralDlg_OnRestoreDefaults(HWND hwndDlg, PGENERAL_DIALOG pGeneral)
Definition: general.cpp:302
static BOOL GeneralDlg_OnApply(HWND hwndDlg, PGENERAL_DIALOG pGeneral)
Definition: general.cpp:315
INT_PTR CALLBACK FolderOptionsGeneralDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.cpp:331
EXTERN_C LSTATUS SHELL32_WriteRegShellState(PREGSHELLSTATE prss)
Definition: general.cpp:51
static void GeneralDlg_StoreToUI(HWND hwndDlg, BOOL bDoubleClick, BOOL bUseCommonTasks, BOOL bUnderline, BOOL bNewWindowMode, PGENERAL_DIALOG pGeneral)
Definition: general.cpp:248
#define ss
Definition: i386-dis.c:441
#define cs
Definition: i386-dis.c:442
#define S_OK
Definition: intsafe.h:52
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HICON
Definition: imagelist.c:80
unsigned int UINT
Definition: ndis.h:50
#define REG_BINARY
Definition: nt_native.h:1496
#define DWORD
Definition: nt_native.h:44
#define REG_NONE
Definition: nt_native.h:1492
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_SETACTIVE
Definition: prsht.h:115
#define err(...)
#define WM_NOTIFY
Definition: richedit.h:61
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
Definition: shellord.c:1806
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
Definition: shellord.c:225
BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
Definition: shellord.c:1858
#define SHFSF_COL_NAME
Definition: shfldr.h:43
#define SSF_DOUBLECLICKINWEBVIEW
Definition: shlobj.h:1610
#define SSF_WEBVIEW
Definition: shlobj.h:1620
#define SHRegSetUSValue
Definition: shlwapi.h:556
#define SHRegGetUSValue
Definition: shlwapi.h:534
#define SHREGSET_HKLM
Definition: shlwapi.h:313
#define SHREGSET_FORCE_HKCU
Definition: shlwapi.h:312
BOOL WINAPI SHSettingsChanged(LPCVOID unused, LPCWSTR pszKey)
Definition: shpolicy.c:178
#define IDC_FOLDER_OPTIONS_CLASSICFOLDERS
Definition: shresdef.h:417
#define IDC_FOLDER_OPTIONS_ULBROWSER
Definition: shresdef.h:422
#define IDC_FOLDER_OPTIONS_SINGLECLICK
Definition: shresdef.h:420
#define IDC_FOLDER_OPTIONS_COMMONTASKS
Definition: shresdef.h:416
#define IDI_SHELL_OPEN_IN_SOME_WINDOW
Definition: shresdef.h:652
#define IDC_FOLDER_OPTIONS_SAMEWINDOW
Definition: shresdef.h:418
#define IDC_FOLDER_OPTIONS_FOLDERICON
Definition: shresdef.h:414
#define IDI_SHELL_OPEN_IN_NEW_WINDOW
Definition: shresdef.h:653
#define IDI_SHELL_CLASSIC_FOLDERS
Definition: shresdef.h:651
#define IDI_SHELL_SINGLE_CLICK_TO_OPEN
Definition: shresdef.h:654
#define IDC_FOLDER_OPTIONS_CLICKICON
Definition: shresdef.h:415
#define IDC_FOLDER_OPTIONS_DOUBLECLICK
Definition: shresdef.h:421
#define IDI_SHELL_DOUBLE_CLICK_TO_OPEN
Definition: shresdef.h:655
#define IDC_FOLDER_OPTIONS_TASKICON
Definition: shresdef.h:413
#define IDC_FOLDER_OPTIONS_ULPOINT
Definition: shresdef.h:423
#define IDC_FOLDER_OPTIONS_RESTORE
Definition: shresdef.h:424
#define IDC_FOLDER_OPTIONS_OWNWINDOW
Definition: shresdef.h:419
#define IDI_SHELL_SHOW_COMMON_TASKS
Definition: shresdef.h:650
HICON hFolderIcon
Definition: general.cpp:155
HICON hClickIcon
Definition: general.cpp:156
HICON hTaskIcon
Definition: general.cpp:154
SHELLSTATE ss
Definition: ShellState.cpp:22
BOOL fShowSuperHidden
Definition: shlobj.h:1557
BOOL fShowExtensions
Definition: shlobj.h:1542
LONG lParamSort
Definition: shlobj.h:1563
BOOL fWebView
Definition: shlobj.h:1555
BOOL fShowAttribCol
Definition: shlobj.h:1551
BOOL fShowCompColor
Definition: shlobj.h:1546
BOOL fShowInfoTip
Definition: shlobj.h:1553
UINT version
Definition: shlobj.h:1565
BOOL fSepProcess
Definition: shlobj.h:1567
int iSortDirection
Definition: shlobj.h:1564
BOOL fShowAllObjects
Definition: shlobj.h:1541
BOOL fDoubleClickInWebView
Definition: shlobj.h:1547
BOOL fStartPanelOn
Definition: shlobj.h:1568
UINT code
Definition: winuser.h:3162
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define REGSHELLSTATE_VERSION
Definition: undocshell.h:566
#define REGSHELLSTATE_SIZE
Definition: undocshell.h:565
#define CWM_STATECHANGE
Definition: undocshell.h:225
void PostCabinetMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: view.cpp:880
#define ZeroMemory
Definition: winbase.h:1737
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define S_FALSE
Definition: winerror.h:2357
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define STM_SETIMAGE
Definition: winuser.h:2096
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5855
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
#define LoadImage
Definition: winuser.h:5827
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1090
#define BN_CLICKED
Definition: winuser.h:1928
#define WM_DESTROY
Definition: winuser.h:1612
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185