ReactOS 0.4.15-dev-5666-gc548b97
view.cpp
Go to the documentation of this file.
1/*
2 * 'View' 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// View Tree
28
29// predefined icon IDs (See ViewDlg_CreateTreeImageList function below)
30#define I_CHECKED 0
31#define I_UNCHECKED 1
32#define I_CHECKED_DISABLED 2
33#define I_UNCHECKED_DISABLED 3
34#define I_RADIO_CHECKED 4
35#define I_RADIO_UNCHECKED 5
36#define I_RADIO_CHECKED_DISABLED 6
37#define I_RADIO_UNCHECKED_DISABLED 7
38#define PREDEFINED_ICON_COUNT 8
39
40// uniquely-defined icon entry for View Advanced Settings
41typedef struct VIEWTREE_ICON
42{
46
47// types of View Advanced Setting entry
49{
54
55// an entry info of View Advanced Settings
56typedef struct VIEWTREE_ENTRY
57{
58 DWORD dwID; // entry ID
59 DWORD dwParentID; // parent entry ID
60 DWORD dwResourceID; // resource ID
61 WCHAR szKeyName[64]; // entry key name
62 DWORD dwType; // VIEWTREE_ENTRY_TYPE
64 INT nIconID; // icon ID (See VIEWTREE_ICON)
65
66 HKEY hkeyRoot; // registry root key
67 WCHAR szRegPath[MAX_PATH]; // registry path
68 WCHAR szValueName[64]; // registry value name
69
70 DWORD dwCheckedValue; // checked value
71 DWORD dwUncheckedValue; // unchecked value
72 DWORD dwDefaultValue; // defalut value
73 BOOL bHasUncheckedValue; // If FALSE, UncheckedValue is invalid
74
75 HTREEITEM hItem; // for TreeView
76 BOOL bGrayed; // disabled?
77 BOOL bChecked; // checked?
79
80// definition of view advanced entries
83
84// definition of icon stock
88
89static INT
90ViewTree_FindIcon(LPCWSTR pszPath, UINT nIconIndex)
91{
93 {
95 if (pIcon->nIconIndex == nIconIndex &&
96 lstrcmpiW(pIcon->szPath, pszPath) == 0)
97 {
98 return i; // icon ID
99 }
100 }
101 return -1; // not found
102}
103
104static INT
105ViewTree_AddIcon(LPCWSTR pszPath, UINT nIconIndex)
106{
107 PVIEWTREE_ICON pAllocated;
108
109 // return the ID if already existed
110 INT nIconID = ViewTree_FindIcon(pszPath, nIconIndex);
111 if (nIconID != -1)
112 return nIconID; // already exists
113
114 // extract a small icon
115 HICON hIconSmall = NULL;
116 ExtractIconExW(pszPath, nIconIndex, NULL, &hIconSmall, 1);
117 if (hIconSmall == NULL)
118 return -1; // failure
119
120 // resize s_ViewTreeIcons
121 size_t Size = (s_ViewTreeIconCount + 1) * sizeof(VIEWTREE_ICON);
123 if (pAllocated == NULL)
124 return -1; // failure
125 else
126 s_ViewTreeIcons = pAllocated;
127
128 // save icon information
130 lstrcpynW(pIcon->szPath, pszPath, _countof(pIcon->szPath));
131 pIcon->nIconIndex = nIconIndex;
132
133 // add the icon to the image list
135
136 // increment the counter
137 nIconID = s_ViewTreeIconCount;
139
140 DestroyIcon(hIconSmall);
141
142 return nIconID; // newly-added icon ID
143}
144
145static PVIEWTREE_ENTRY
147{
148 if (dwID == DWORD(-1))
149 return NULL;
150
151 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
152 {
154 if (pEntry->dwID == dwID)
155 return pEntry;
156 }
157 return NULL; // failure
158}
159
160static INT
162{
163 switch (pEntry->dwType)
164 {
165 case AETYPE_GROUP:
166 return pEntry->nIconID;
167
168 case AETYPE_CHECKBOX:
169 if (pEntry->bGrayed)
170 {
171 if (pEntry->bChecked)
172 return I_CHECKED_DISABLED;
173 else
175 }
176 else
177 {
178 if (pEntry->bChecked)
179 return I_CHECKED;
180 else
181 return I_UNCHECKED;
182 }
183
184 case AETYPE_RADIO:
185 if (pEntry->bGrayed)
186 {
187 if (pEntry->bChecked)
189 else
191 }
192 else
193 {
194 if (pEntry->bChecked)
195 return I_RADIO_CHECKED;
196 else
197 return I_RADIO_UNCHECKED;
198 }
199 }
200 return -1; // failure
201}
202
203static VOID
205{
207 HTREEITEM hParent = TVI_ROOT;
208 if (pParent)
209 hParent = pParent->hItem;
210
211 TV_INSERTSTRUCT Insertion;
212 ZeroMemory(&Insertion, sizeof(Insertion));
213 Insertion.hParent = hParent;
214 Insertion.hInsertAfter = TVI_LAST;
215 Insertion.item.mask =
217 Insertion.item.pszText = pEntry->szText;
218
219 INT iImage = ViewTree_GetImage(pEntry);
220 Insertion.item.iImage = Insertion.item.iSelectedImage = iImage;
221 Insertion.item.lParam = pEntry->dwID;
222 pEntry->hItem = TreeView_InsertItem(hwndTreeView, &Insertion);
223}
224
225static VOID
227{
229
230 // insert the entries
232 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
233 {
236 }
237
238 // expand all
239 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
240 {
242 if (pEntry->dwType == AETYPE_GROUP)
243 {
245 }
246 }
247}
248
249static BOOL
250ViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID)
251{
252 DWORD dwIndex;
253 WCHAR szKeyName[64], szText[MAX_PATH], *pch;
255 PVIEWTREE_ENTRY pAllocated;
256
257 // resize s_ViewTreeEntries
258 Size = (s_ViewTreeEntryCount + 1) * sizeof(VIEWTREE_ENTRY);
260 if (pAllocated == NULL)
261 return FALSE; // failure
262 else
263 s_ViewTreeEntries = pAllocated;
264
266
267 // dwID, dwParentID, szKeyName
269 pEntry->dwParentID = dwParentID;
270 lstrcpynW(pEntry->szKeyName, pszKeyName, _countof(pEntry->szKeyName));
271
272 // Text, ResourceID
273 pEntry->szText[0] = 0;
274 pEntry->dwResourceID = 0;
275 szText[0] = 0;
276 Size = sizeof(szText);
277 RegQueryValueExW(hKey, L"Text", NULL, NULL, LPBYTE(szText), &Size);
278 if (szText[0] == L'@')
279 {
280 pch = wcsrchr(szText, L',');
281 if (pch)
282 {
283 *pch = 0;
284 dwIndex = abs(_wtoi(pch + 1));
285 pEntry->dwResourceID = dwIndex;
286 }
287 HINSTANCE hInst = LoadLibraryW(&szText[1]);
288 LoadStringW(hInst, dwIndex, szText, _countof(szText));
290 }
291 else
292 {
293 pEntry->dwResourceID = DWORD(-1);
294 }
295 lstrcpynW(pEntry->szText, szText, _countof(pEntry->szText));
296
297 // Type
298 szText[0] = 0;
299 RegQueryValueExW(hKey, L"Type", NULL, NULL, LPBYTE(szText), &Size);
300 if (lstrcmpiW(szText, L"checkbox") == 0)
301 pEntry->dwType = AETYPE_CHECKBOX;
302 else if (lstrcmpiW(szText, L"radio") == 0)
303 pEntry->dwType = AETYPE_RADIO;
304 else if (lstrcmpiW(szText, L"group") == 0)
305 pEntry->dwType = AETYPE_GROUP;
306 else
307 return FALSE; // failure
308
309 pEntry->nIconID = -1;
310 if (pEntry->dwType == AETYPE_GROUP)
311 {
312 // Bitmap (Icon)
313 UINT nIconIndex = 0;
314 Size = sizeof(szText);
315 szText[0] = 0;
316 RegQueryValueExW(hKey, L"Bitmap", NULL, NULL, LPBYTE(szText), &Size);
317
318 WCHAR szExpanded[MAX_PATH];
319 ExpandEnvironmentStringsW(szText, szExpanded, _countof(szExpanded));
320 pch = wcsrchr(szExpanded, L',');
321 if (pch)
322 {
323 *pch = 0;
324 nIconIndex = abs(_wtoi(pch + 1));
325 }
326 pEntry->nIconID = ViewTree_AddIcon(szExpanded, nIconIndex);
327 }
328
329 if (pEntry->dwType == AETYPE_GROUP)
330 {
331 pEntry->hkeyRoot = NULL;
332 pEntry->szRegPath[0] = 0;
333 pEntry->szValueName[0] = 0;
334 pEntry->dwCheckedValue = 0;
335 pEntry->bHasUncheckedValue = FALSE;
336 pEntry->dwUncheckedValue = 0;
337 pEntry->dwDefaultValue = 0;
338 pEntry->hItem = NULL;
339 pEntry->bGrayed = FALSE;
340 pEntry->bChecked = FALSE;
341 }
342 else
343 {
344 // HKeyRoot
345 HKEY HKeyRoot = HKEY_CURRENT_USER;
346 Size = sizeof(HKeyRoot);
347 RegQueryValueExW(hKey, L"HKeyRoot", NULL, NULL, LPBYTE(&HKeyRoot), &Size);
348 pEntry->hkeyRoot = HKeyRoot;
349
350 // RegPath
351 pEntry->szRegPath[0] = 0;
352 Size = sizeof(szText);
353 RegQueryValueExW(hKey, L"RegPath", NULL, NULL, LPBYTE(szText), &Size);
354 lstrcpynW(pEntry->szRegPath, szText, _countof(pEntry->szRegPath));
355
356 // ValueName
357 pEntry->szValueName[0] = 0;
358 Size = sizeof(szText);
359 RegQueryValueExW(hKey, L"ValueName", NULL, NULL, LPBYTE(szText), &Size);
360 lstrcpynW(pEntry->szValueName, szText, _countof(pEntry->szValueName));
361
362 // CheckedValue
363 Size = sizeof(Value);
364 Value = 0x00000001;
365 RegQueryValueExW(hKey, L"CheckedValue", NULL, NULL, LPBYTE(&Value), &Size);
366 pEntry->dwCheckedValue = Value;
367
368 // UncheckedValue
369 Size = sizeof(Value);
370 Value = 0x00000000;
371 pEntry->bHasUncheckedValue = TRUE;
372 if (RegQueryValueExW(hKey, L"UncheckedValue", NULL,
374 {
375 pEntry->bHasUncheckedValue = FALSE;
376 }
377 pEntry->dwUncheckedValue = Value;
378
379 // DefaultValue
380 Size = sizeof(Value);
381 Value = 0x00000001;
382 RegQueryValueExW(hKey, L"DefaultValue", NULL, NULL, LPBYTE(&Value), &Size);
383 pEntry->dwDefaultValue = Value;
384
385 // hItem
386 pEntry->hItem = NULL;
387
388 // bGrayed, bChecked
389 HKEY hkeyTarget;
390 Value = pEntry->dwDefaultValue;
391 pEntry->bGrayed = TRUE;
392 if (RegOpenKeyExW(HKEY(pEntry->hkeyRoot), pEntry->szRegPath, 0,
393 KEY_READ, &hkeyTarget) == ERROR_SUCCESS)
394 {
395 Size = sizeof(Value);
396 if (RegQueryValueExW(hkeyTarget, pEntry->szValueName, NULL, NULL,
398 {
399 pEntry->bGrayed = FALSE;
400 }
401 RegCloseKey(hkeyTarget);
402 }
403 pEntry->bChecked = (Value == pEntry->dwCheckedValue);
404 }
405
406 // Grayed (ReactOS extension)
407 Size = sizeof(Value);
408 Value = FALSE;
409 RegQueryValueExW(hKey, L"Grayed", NULL, NULL, LPBYTE(&Value), &Size);
410 if (!pEntry->bGrayed)
411 pEntry->bGrayed = Value;
412
413 BOOL bIsGroup = (pEntry->dwType == AETYPE_GROUP);
414 dwParentID = pEntry->dwID;
416
417 if (!bIsGroup)
418 return TRUE; // success
419
420 // load the children
421 dwIndex = 0;
422 while (RegEnumKeyW(hKey, dwIndex, szKeyName,
423 _countof(szKeyName)) == ERROR_SUCCESS)
424 {
425 HKEY hkeyChild;
426 if (RegOpenKeyExW(hKey, szKeyName, 0, KEY_READ,
427 &hkeyChild) != ERROR_SUCCESS)
428 {
429 ++dwIndex;
430 continue; // failure
431 }
432
433 ViewTree_LoadTree(hkeyChild, szKeyName, dwParentID);
434 RegCloseKey(hkeyChild);
435
436 ++dwIndex;
437 }
438
439 return TRUE; // success
440}
441
443{
444 // free if already existed
446 {
449 }
451
452 HKEY hKey;
454 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
455 0, KEY_READ, &hKey) != ERROR_SUCCESS)
456 {
457 return FALSE; // failure
458 }
459
460 // load the children
461 WCHAR szKeyName[64];
462 DWORD dwIndex = 0;
463 while (RegEnumKeyW(hKey, dwIndex, szKeyName,
464 _countof(szKeyName)) == ERROR_SUCCESS)
465 {
466 HKEY hkeyChild;
467 if (RegOpenKeyExW(hKey, szKeyName, 0, KEY_READ,
468 &hkeyChild) != ERROR_SUCCESS)
469 {
470 ++dwIndex;
471 continue; // failure
472 }
473
474 ViewTree_LoadTree(hkeyChild, szKeyName, DWORD(-1));
475 RegCloseKey(hkeyChild);
476
477 ++dwIndex;
478 }
479
481
482 return TRUE; // success
483}
484
485static int ViewTree_Compare(const void *x, const void *y)
486{
489
490 DWORD dwParentID1 = pEntry1->dwParentID;
491 DWORD dwParentID2 = pEntry2->dwParentID;
492
493 if (dwParentID1 == dwParentID2)
494 return lstrcmpi(pEntry1->szText, pEntry2->szText);
495
496 DWORD i, m, n;
497 const UINT MAX_DEPTH = 32;
498 PVIEWTREE_ENTRY pArray1[MAX_DEPTH];
499 PVIEWTREE_ENTRY pArray2[MAX_DEPTH];
500
501 // Make ancestor lists
502 for (i = m = n = 0; i < MAX_DEPTH; ++i)
503 {
504 PVIEWTREE_ENTRY pParent1 = ViewTree_GetItem(dwParentID1);
505 PVIEWTREE_ENTRY pParent2 = ViewTree_GetItem(dwParentID2);
506 if (!pParent1 && !pParent2)
507 break;
508
509 if (pParent1)
510 {
511 pArray1[m++] = pParent1;
512 dwParentID1 = pParent1->dwParentID;
513 }
514 if (pParent2)
515 {
516 pArray2[n++] = pParent2;
517 dwParentID2 = pParent2->dwParentID;
518 }
519 }
520
521 UINT k = min(m, n);
522 for (i = 0; i < k; ++i)
523 {
524 INT nCompare = lstrcmpi(pArray1[m - i - 1]->szText, pArray2[n - i - 1]->szText);
525 if (nCompare < 0)
526 return -1;
527 if (nCompare > 0)
528 return 1;
529 }
530
531 if (m < n)
532 return -1;
533 if (m > n)
534 return 1;
535 return lstrcmpi(pEntry1->szText, pEntry2->szText);
536}
537
538static VOID
540{
542}
543
545// ViewDlg
546
547static HIMAGELIST
549{
550 HIMAGELIST hImageList;
551 hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 9, 1);
552 if (hImageList == NULL)
553 return NULL; // failure
554
555 // free if existed
556 if (s_ViewTreeIcons)
557 {
560 }
562
563 // allocate now
564 PVIEWTREE_ICON pAllocated;
565 size_t Size = PREDEFINED_ICON_COUNT * sizeof(VIEWTREE_ICON);
566 pAllocated = (PVIEWTREE_ICON)calloc(1, Size);
567 if (pAllocated == NULL)
568 return NULL; // failure
569
571 s_ViewTreeIcons = pAllocated;
572
573 // add the predefined icons
574
576 HBITMAP hbmMask = CreateCheckMask(hDC);
577
578 HBITMAP hbmChecked, hbmUnchecked;
579
580 hbmChecked = CreateCheckImage(hDC, TRUE);
581 ImageList_Add(hImageList, hbmChecked, hbmMask);
582 DeleteObject(hbmChecked);
583
584 hbmUnchecked = CreateCheckImage(hDC, FALSE);
585 ImageList_Add(hImageList, hbmUnchecked, hbmMask);
586 DeleteObject(hbmUnchecked);
587
588 hbmChecked = CreateCheckImage(hDC, TRUE, FALSE);
589 ImageList_Add(hImageList, hbmChecked, hbmMask);
590 DeleteObject(hbmChecked);
591
592 hbmUnchecked = CreateCheckImage(hDC, FALSE, FALSE);
593 ImageList_Add(hImageList, hbmUnchecked, hbmMask);
594 DeleteObject(hbmUnchecked);
595
596 DeleteObject(hbmMask);
597 hbmMask = CreateRadioMask(hDC);
598
599 hbmChecked = CreateRadioImage(hDC, TRUE);
600 ImageList_Add(hImageList, hbmChecked, hbmMask);
601 DeleteObject(hbmChecked);
602
603 hbmUnchecked = CreateRadioImage(hDC, FALSE);
604 ImageList_Add(hImageList, hbmUnchecked, hbmMask);
605 DeleteObject(hbmUnchecked);
606
607 hbmChecked = CreateRadioImage(hDC, TRUE, FALSE);
608 ImageList_Add(hImageList, hbmChecked, hbmMask);
609 DeleteObject(hbmChecked);
610
611 hbmUnchecked = CreateRadioImage(hDC, FALSE, FALSE);
612 ImageList_Add(hImageList, hbmUnchecked, hbmMask);
613 DeleteObject(hbmUnchecked);
614
615 DeleteObject(hbmMask);
616
617 return hImageList;
618}
619
620static BOOL
622{
624
627
631
632 return TRUE; // set focus
633}
634
635static BOOL
637{
639
640 // get the item
642 INT i;
643 ZeroMemory(&Item, sizeof(Item));
645 Item.hItem = hItem;
647 return FALSE; // no such item
648
650 if (pEntry == NULL)
651 return FALSE; // no such item
652 if (pEntry->bGrayed)
653 return FALSE; // disabled
654
655 // toggle check mark
657 switch (pEntry->dwType)
658 {
659 case AETYPE_CHECKBOX:
660 pEntry->bChecked = !pEntry->bChecked;
661 break;
662
663 case AETYPE_RADIO:
664 // reset all the entries of the same parent
665 for (i = 0; i < s_ViewTreeEntryCount; ++i)
666 {
668 if (pEntry->dwParentID == pEntry2->dwParentID)
669 {
670 pEntry2->bChecked = FALSE;
671
672 Item.hItem = pEntry2->hItem;
673 INT iImage = ViewTree_GetImage(pEntry2);
674 Item.iImage = Item.iSelectedImage = iImage;
676 }
677 }
678 pEntry->bChecked = TRUE;
679 break;
680
681 default:
682 return FALSE; // failure
683 }
684 Item.iImage = Item.iSelectedImage = ViewTree_GetImage(pEntry);
685 Item.hItem = hItem;
687
688 // redraw the item
689 RECT rcItem;
692 return TRUE; // success
693}
694
695static VOID
697{
699
700 // do hit test to get the clicked item
701 TV_HITTESTINFO HitTest;
702 ZeroMemory(&HitTest, sizeof(HitTest));
703 DWORD dwPos = GetMessagePos();
704 HitTest.pt.x = LOWORD(dwPos);
705 HitTest.pt.y = HIWORD(dwPos);
706 ScreenToClient(hwndTreeView, &HitTest.pt);
708
709 // toggle the check mark if possible
710 if (ViewDlg_ToggleCheckItem(hwndDlg, hItem))
711 {
712 // property sheet was changed
713 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
714 }
715}
716
717static void
719{
721
722 if (KeyDown->wVKey == VK_SPACE)
723 {
724 // [Space] key was pressed
726 if (ViewDlg_ToggleCheckItem(hwndDlg, hItem))
727 {
728 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
729 }
730 }
731}
732
733static INT_PTR
735{
736 NMCUSTOMDRAW& nmcd = Draw->nmcd;
737 switch (nmcd.dwDrawStage)
738 {
739 case CDDS_PREPAINT:
740 return CDRF_NOTIFYITEMDRAW; // for CDDS_ITEMPREPAINT
741
743 if (!(nmcd.uItemState & CDIS_SELECTED)) // not selected
744 {
747 if (pEntry && pEntry->bGrayed) // disabled
748 {
749 // draw as grayed
750 Draw->clrText = GetSysColor(COLOR_GRAYTEXT);
751 Draw->clrTextBk = GetSysColor(COLOR_WINDOW);
752 return CDRF_NEWFONT;
753 }
754 }
755 break;
756
757 default:
758 break;
759 }
760 return CDRF_DODEFAULT;
761}
762
763static VOID
765{
767
768 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
769 {
770 // ignore if the type is group
772 if (pEntry->dwType == AETYPE_GROUP)
773 continue;
774
775 // set default value on registry
776 HKEY hKey;
777 if (RegOpenKeyExW(HKEY(pEntry->hkeyRoot), pEntry->szRegPath,
779 {
780 continue;
781 }
782 RegSetValueExW(hKey, pEntry->szValueName, 0, REG_DWORD,
783 LPBYTE(&pEntry->dwDefaultValue), sizeof(DWORD));
785
786 // update check status
787 pEntry->bChecked = (pEntry->dwCheckedValue == pEntry->dwDefaultValue);
788
789 // update the image
791 ZeroMemory(&Item, sizeof(Item));
793 Item.hItem = pEntry->hItem;
794 Item.iImage = Item.iSelectedImage = ViewTree_GetImage(pEntry);
796 }
797
798 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
799}
800
801static VOID
803{
804 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
805 {
807 if (pEntry->dwType == AETYPE_GROUP || pEntry->bGrayed)
808 continue;
809
810 BOOL bChecked = pEntry->bChecked;
811
812 // FIXME: Add more items
813 if (lstrcmpiW(pEntry->szKeyName, L"SuperHidden") == 0)
814 {
815 pSS->fShowSuperHidden = !bChecked ? 1 : 0;
816 *pdwMask |= SSF_SHOWSUPERHIDDEN;
817 continue;
818 }
819 if (lstrcmpiW(pEntry->szKeyName, L"DesktopProcess") == 0)
820 {
821 pSS->fSepProcess = bChecked ? 1 : 0;
822 *pdwMask |= SSF_SEPPROCESS;
823 continue;
824 }
825 if (lstrcmpiW(pEntry->szKeyName, L"SHOWALL") == 0)
826 {
827 pSS->fShowAllObjects = !bChecked ? 1 : 0;
828 *pdwMask |= SSF_SHOWALLOBJECTS;
829 continue;
830 }
831 if (lstrcmpiW(pEntry->szKeyName, L"HideFileExt") == 0)
832 {
833 pSS->fShowExtensions = !bChecked ? 1 : 0;
834 *pdwMask |= SSF_SHOWEXTENSIONS;
835 continue;
836 }
837 if (lstrcmpiW(pEntry->szKeyName, L"ShowCompColor") == 0)
838 {
839 pSS->fShowCompColor = bChecked ? 1 : 0;
840 *pdwMask |= SSF_SHOWCOMPCOLOR;
841 continue;
842 }
843 if (lstrcmpiW(pEntry->szKeyName, L"ShowInfoTip") == 0)
844 {
845 pSS->fShowInfoTip = bChecked ? 1 : 0;
846 *pdwMask |= SSF_SHOWINFOTIP;
847 continue;
848 }
849 }
850}
851
852static BOOL CALLBACK
854{
855 WCHAR ClassName[100];
856 if (GetClassNameW(hWnd, ClassName, _countof(ClassName)))
857 {
858 if (!wcscmp(ClassName, L"Progman") ||
859 !wcscmp(ClassName, L"CabinetWClass") ||
860 !wcscmp(ClassName, L"ExploreWClass"))
861 {
863 }
864 }
865 return TRUE;
866}
867
868static VOID
870{
871 for (INT i = 0; i < s_ViewTreeEntryCount; ++i)
872 {
873 // ignore the entry if the type is group or the entry is grayed
875 if (pEntry->dwType == AETYPE_GROUP || pEntry->bGrayed)
876 continue;
877
878 // open the registry key
879 HKEY hkeyTarget;
880 if (RegOpenKeyExW(HKEY(pEntry->hkeyRoot), pEntry->szRegPath, 0,
881 KEY_WRITE, &hkeyTarget) != ERROR_SUCCESS)
882 {
883 continue;
884 }
885
886 // checked or unchecked?
887 DWORD dwValue, dwSize;
888 if (pEntry->bChecked)
889 {
890 dwValue = pEntry->dwCheckedValue;
891 }
892 else
893 {
894 if (pEntry->bHasUncheckedValue)
895 {
896 dwValue = pEntry->dwUncheckedValue;
897 }
898 else
899 {
900 // there is no unchecked value
901 RegCloseKey(hkeyTarget);
902 continue; // ignore
903 }
904 }
905
906 // set the value
907 dwSize = sizeof(dwValue);
908 RegSetValueExW(hkeyTarget, pEntry->szValueName, 0, REG_DWORD,
909 LPBYTE(&dwValue), dwSize);
910
911 // close now
912 RegCloseKey(hkeyTarget);
913 }
914
915 // scan advanced settings for user's settings
916 DWORD dwMask = 0;
917 SHELLSTATE ShellState;
918 ZeroMemory(&ShellState, sizeof(ShellState));
919 ScanAdvancedSettings(&ShellState, &dwMask);
920
921 // update user's settings
922 SHGetSetSettings(&ShellState, dwMask, TRUE);
923
924 // notify all
926
928}
929
930// IDD_FOLDER_OPTIONS_VIEW
933 HWND hwndDlg,
934 UINT uMsg,
937{
940
941 switch (uMsg)
942 {
943 case WM_INITDIALOG:
944 return ViewDlg_OnInitDialog(hwndDlg);
945
946 case WM_COMMAND:
947 switch (LOWORD(wParam))
948 {
949 case IDC_VIEW_RESTORE_DEFAULTS: // Restore Defaults
951 break;
952 }
953 break;
954
955 case WM_NOTIFY:
956 switch (LPNMHDR(lParam)->code)
957 {
958 case NM_CLICK: // clicked on treeview
960 break;
961
962 case NM_CUSTOMDRAW: // custom draw (for graying)
966 return Result;
967
968 case TVN_KEYDOWN: // key is down
970 break;
971
972 case PSN_APPLY: // [Apply] is clicked
973 ViewDlg_Apply(hwndDlg);
974 break;
975
976 default:
977 break;
978 }
979 break;
980 }
981
982 return FALSE;
983}
static HDC hDC
Definition: 3dtext.c:33
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HANDLE HKEY
Definition: registry.h:26
#define RegCloseKey(hKey)
Definition: registry.h:47
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FCIDM_DESKBROWSER_REFRESH
Definition: desktop.c:14
#define MAX_DEPTH
Definition: config.h:145
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
INT WINAPI ImageList_Add(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
Definition: imagelist.c:448
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define wcsrchr
Definition: compat.h:16
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define LoadLibraryW(x)
Definition: compat.h:747
#define lstrcpynW
Definition: compat.h:738
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HINSTANCE hInst
Definition: dxdiag.c:13
HWND hwndTreeView
Definition: eventvwr.c:65
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HBITMAP CreateRadioMask(HDC hDC)
HBITMAP CreateCheckMask(HDC hDC)
HBITMAP CreateRadioImage(HDC hDC, BOOL bCheck, BOOL bEnabled)
HBITMAP CreateCheckImage(HDC hDC, BOOL bCheck, BOOL bEnabled)
FxObject * pParent
Definition: fxdpcapi.cpp:86
FxAutoRegKey hKey
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:866
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
void Draw(HDC aDc)
Definition: magnifier.c:359
#define pch(ap)
Definition: match.c:418
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define DWORD
Definition: nt_native.h:44
#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 TVN_KEYDOWN
Definition: commctrl.h:3713
#define TVI_LAST
Definition: commctrl.h:3370
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define TVIF_TEXT
Definition: commctrl.h:3266
#define CDDS_ITEMPREPAINT
Definition: commctrl.h:285
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define CDRF_NOTIFYITEMDRAW
Definition: commctrl.h:275
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define CDRF_DODEFAULT
Definition: commctrl.h:268
#define TV_HITTESTINFO
Definition: commctrl.h:3516
#define CDIS_SELECTED
Definition: commctrl.h:291
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define NM_CLICK
Definition: commctrl.h:130
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3429
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TV_INSERTSTRUCT
Definition: commctrl.h:3377
#define TVI_ROOT
Definition: commctrl.h:3368
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define TV_ITEM
Definition: commctrl.h:3300
#define CDRF_NEWFONT
Definition: commctrl.h:269
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define CDDS_PREPAINT
Definition: commctrl.h:280
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TV_KEYDOWN
Definition: commctrl.h:3722
#define ILC_MASK
Definition: commctrl.h:351
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3513
#define ILC_COLOR24
Definition: commctrl.h:357
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define WM_NOTIFY
Definition: richedit.h:61
#define calloc
Definition: rosglue.h:14
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
Definition: shellord.c:201
#define SSF_SEPPROCESS
Definition: shlobj.h:1541
#define SSF_SHOWCOMPCOLOR
Definition: shlobj.h:1529
#define SSF_SHOWEXTENSIONS
Definition: shlobj.h:1528
#define SSF_SHOWSUPERHIDDEN
Definition: shlobj.h:1540
#define SSF_SHOWALLOBJECTS
Definition: shlobj.h:1527
#define SSF_SHOWINFOTIP
Definition: shlobj.h:1536
#define IDC_VIEW_TREEVIEW
Definition: shresdef.h:483
#define IDC_VIEW_RESTORE_DEFAULTS
Definition: shresdef.h:484
#define _countof(array)
Definition: sndvol32.h:68
BOOL fShowSuperHidden
Definition: shlobj.h:1482
BOOL fShowExtensions
Definition: shlobj.h:1467
BOOL fShowCompColor
Definition: shlobj.h:1471
BOOL fShowInfoTip
Definition: shlobj.h:1478
BOOL fSepProcess
Definition: shlobj.h:1492
BOOL fShowAllObjects
Definition: shlobj.h:1466
Definition: view.cpp:57
HKEY hkeyRoot
Definition: view.cpp:66
BOOL bHasUncheckedValue
Definition: view.cpp:73
DWORD dwDefaultValue
Definition: view.cpp:72
BOOL bGrayed
Definition: view.cpp:76
DWORD dwParentID
Definition: view.cpp:59
WCHAR szValueName[64]
Definition: view.cpp:68
WCHAR szKeyName[64]
Definition: view.cpp:61
DWORD dwID
Definition: view.cpp:58
DWORD dwType
Definition: view.cpp:62
DWORD dwResourceID
Definition: view.cpp:60
INT nIconID
Definition: view.cpp:64
DWORD dwUncheckedValue
Definition: view.cpp:71
WCHAR szRegPath[MAX_PATH]
Definition: view.cpp:67
BOOL bChecked
Definition: view.cpp:77
HTREEITEM hItem
Definition: view.cpp:75
WCHAR szText[MAX_PATH]
Definition: view.cpp:63
DWORD dwCheckedValue
Definition: view.cpp:70
UINT nIconIndex
Definition: view.cpp:44
WCHAR szPath[MAX_PATH]
Definition: view.cpp:43
Definition: inflate.c:139
#define SetWindowLongPtr
Definition: treelist.c:70
HTREEITEM hItem
Definition: treelist.h:37
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define I_RADIO_UNCHECKED
Definition: view.cpp:35
static INT ViewTree_GetImage(PVIEWTREE_ENTRY pEntry)
Definition: view.cpp:161
static VOID ViewTree_InsertAll(HWND hwndTreeView)
Definition: view.cpp:226
static void ViewDlg_OnTreeViewKeyDown(HWND hwndDlg, TV_KEYDOWN *KeyDown)
Definition: view.cpp:718
static VOID ViewDlg_RestoreDefaults(HWND hwndDlg)
Definition: view.cpp:764
static INT ViewTree_AddIcon(LPCWSTR pszPath, UINT nIconIndex)
Definition: view.cpp:105
INT_PTR CALLBACK FolderOptionsViewDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: view.cpp:932
static INT s_ViewTreeIconCount
Definition: view.cpp:86
static int ViewTree_Compare(const void *x, const void *y)
Definition: view.cpp:485
static BOOL ViewDlg_OnInitDialog(HWND hwndDlg)
Definition: view.cpp:621
static INT_PTR ViewDlg_OnTreeCustomDraw(HWND hwndDlg, NMTVCUSTOMDRAW *Draw)
Definition: view.cpp:734
static BOOL ViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID)
Definition: view.cpp:250
struct VIEWTREE_ENTRY * PVIEWTREE_ENTRY
#define I_CHECKED_DISABLED
Definition: view.cpp:32
#define I_RADIO_CHECKED_DISABLED
Definition: view.cpp:36
static HIMAGELIST s_hTreeImageList
Definition: view.cpp:87
static VOID ViewDlg_Apply(HWND hwndDlg)
Definition: view.cpp:869
static BOOL ViewDlg_ToggleCheckItem(HWND hwndDlg, HTREEITEM hItem)
Definition: view.cpp:636
VIEWTREE_ENTRY_TYPE
Definition: view.cpp:49
@ AETYPE_GROUP
Definition: view.cpp:50
@ AETYPE_CHECKBOX
Definition: view.cpp:51
@ AETYPE_RADIO
Definition: view.cpp:52
#define I_UNCHECKED
Definition: view.cpp:31
#define I_RADIO_UNCHECKED_DISABLED
Definition: view.cpp:37
static PVIEWTREE_ENTRY s_ViewTreeEntries
Definition: view.cpp:81
#define I_UNCHECKED_DISABLED
Definition: view.cpp:33
static BOOL ViewTree_LoadAll(VOID)
Definition: view.cpp:442
static VOID ScanAdvancedSettings(SHELLSTATE *pSS, DWORD *pdwMask)
Definition: view.cpp:802
static VOID ViewTree_SortAll(VOID)
Definition: view.cpp:539
static PVIEWTREE_ENTRY ViewTree_GetItem(DWORD dwID)
Definition: view.cpp:146
static INT ViewTree_FindIcon(LPCWSTR pszPath, UINT nIconIndex)
Definition: view.cpp:90
static BOOL CALLBACK RefreshBrowsersCallback(HWND hWnd, LPARAM msg)
Definition: view.cpp:853
static HIMAGELIST ViewDlg_CreateTreeImageList(VOID)
Definition: view.cpp:548
static INT s_ViewTreeEntryCount
Definition: view.cpp:82
enum VIEWTREE_ENTRY_TYPE * PVIEWTREE_ENTRY_TYPE
#define PREDEFINED_ICON_COUNT
Definition: view.cpp:38
static VOID ViewTree_InsertEntry(HWND hwndTreeView, PVIEWTREE_ENTRY pEntry)
Definition: view.cpp:204
static VOID ViewDlg_OnTreeViewClick(HWND hwndDlg)
Definition: view.cpp:696
#define I_CHECKED
Definition: view.cpp:30
#define I_RADIO_CHECKED
Definition: view.cpp:34
struct VIEWTREE_ICON * PVIEWTREE_ICON
static PVIEWTREE_ICON s_ViewTreeIcons
Definition: view.cpp:85
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define ZeroMemory
Definition: winbase.h:1670
#define lstrcmpi
Definition: winbase.h:3744
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_GRAYTEXT
Definition: winuser.h:926
#define COLOR_WINDOW
Definition: winuser.h:912
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define VK_SPACE
Definition: winuser.h:2209
#define HWND_BROADCAST
Definition: winuser.h:1194
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_WININICHANGE
Definition: winuser.h:1620
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5833
#define PostMessage
Definition: winuser.h:5822
HWND WINAPI GetParent(_In_ HWND)
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define DWLP_MSGRESULT
Definition: winuser.h:864
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185