2 * Open With Context Menu extension
4 * Copyright 2007 Johannes Anderwald <janderwald@reactos.org>
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.
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.
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 St, Fifth Floor, Boston, MA 02110-1301, USA
24 WINE_DEFAULT_DEBUG_CHANNEL (fprop
);
25 #define MAX_PROPERTY_SHEET_PAGE (32)
28 /// CLASSKEY = HKEY_CLASSES_ROOT\CLSID\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}
29 /// DefaultIcon = %SystemRoot%\system32\SHELL32.dll,-210
30 /// Verbs: Open / RunAs
31 /// Cmd: rundll32.exe shell32.dll,Options_RunDLL 0
33 /// ShellFolder Attributes: 0x0
41 WCHAR szFolderPath
[MAX_PATH
];
42 }FOLDER_PROPERTIES_CONTEXT
, *PFOLDER_PROPERTIES_CONTEXT
;
46 WCHAR FileExtension
[30];
47 WCHAR FileDescription
[100];
48 WCHAR ClassKey
[MAX_PATH
];
49 }FOLDER_FILE_TYPE_ENTRY
, *PFOLDER_FILE_TYPE_ENTRY
;
55 }FOLDER_VIEW_ENTRY
, PFOLDER_VIEW_ENTRY
;
57 static FOLDER_VIEW_ENTRY s_Options[] =
59 { L"AlwaysShowMenus", IDS_ALWAYSSHOWMENUS },
60 { L"AutoCheckSelect", -1 },
61 { L"ClassicViewState", -1 },
62 { L"DontPrettyPath", -1 },
64 { L"FolderContentsInfoTip", IDS_FOLDERCONTENTSTIP },
65 { L"FriendlyTree", -1 },
67 { L"HideFileExt", IDS_HIDEFILEEXT },
70 { L"ListviewAlphaSelect", -1},
71 { L"ListviewShadow", -1},
72 { L"ListviewWatermark", -1},
73 { L"MapNetDrvBtn", -1},
74 { L"PersistBrowsers", -1},
75 { L"SeperateProcess", IDS_SEPERATEPROCESS},
76 { L"ServerAdminUI", -1},
77 { L"SharingWizardOn", IDS_USESHAREWIZARD},
78 { L"ShowCompColor", IDS_COMPCOLOR},
79 { L"ShowInfoTip", IDS_SHOWINFOTIP},
80 { L"ShowPreviewHandlers", -1},
81 { L"ShowSuperHidden", IDS_HIDEOSFILES},
82 { L"ShowTypeOverlay", -1},
83 { L"Start_ShowMyGames", -1},
84 { L"StartMenuInit", -1},
85 { L"SuperHidden", -1},
93 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, IDataObject
*pDataObj
);
97 FolderOptionsGeneralDlg(
112 InitializeFolderOptionsListCtrl(HWND hwndDlg
)
119 hDlgCtrl
= GetDlgItem(hwndDlg
, 14003);
121 if (!LoadStringW(shell32_hInstance
, IDS_COLUMN_EXTENSION
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
123 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = 0;
125 GetClientRect(hDlgCtrl
, &clientRect
);
126 ZeroMemory(&col
, sizeof(LV_COLUMN
));
127 col
.mask
= LVCF_SUBITEM
| LVCF_WIDTH
| LVCF_FMT
;
129 col
.pszText
= szName
;
130 col
.fmt
= LVCFMT_LEFT
;
131 col
.cx
= (clientRect
.right
- clientRect
.left
) - GetSystemMetrics(SM_CXVSCROLL
);
132 (void)SendMessageW(hDlgCtrl
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
141 FolderOptionsViewDlg(
151 InitializeFolderOptionsListCtrl(hwndDlg
);
160 InitializeFileTypesListCtrlColumns(HWND hDlgCtrl
)
166 int columnSize
= 140;
169 if (!LoadStringW(shell32_hInstance
, IDS_COLUMN_EXTENSION
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
171 /* default to english */
172 wcscpy(szName
, L
"Extensions");
175 /* make sure its null terminated */
176 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = 0;
178 GetClientRect(hDlgCtrl
, &clientRect
);
179 ZeroMemory(&col
, sizeof(LV_COLUMN
));
180 columnSize
= 140; //FIXME
182 col
.mask
= LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
| LVCF_FMT
;
183 col
.fmt
= LVCFMT_FIXED_WIDTH
;
184 col
.cx
= columnSize
| LVCFMT_LEFT
;
185 col
.cchTextMax
= wcslen(szName
);
186 col
.pszText
= szName
;
187 (void)SendMessageW(hDlgCtrl
, LVM_INSERTCOLUMNW
, 0, (LPARAM
)&col
);
189 if (!LoadStringW(shell32_hInstance
, IDS_FILE_TYPES
, szName
, sizeof(szName
) / sizeof(WCHAR
)))
191 /* default to english */
192 wcscpy(szName
, L
"FileTypes");
196 col
.cx
= clientRect
.right
- clientRect
.left
- columnSize
;
197 col
.cchTextMax
= wcslen(szName
);
198 col
.pszText
= szName
;
199 (void)SendMessageW(hDlgCtrl
, LVM_INSERTCOLUMNW
, 1, (LPARAM
)&col
);
201 /* set full select style */
202 dwStyle
= (DWORD
) SendMessage(hDlgCtrl
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
203 dwStyle
= dwStyle
| LVS_EX_FULLROWSELECT
;
204 SendMessage(hDlgCtrl
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, dwStyle
);
209 FindItem(HWND hDlgCtrl
, WCHAR
* ItemName
)
211 LVFINDINFOW findInfo
;
212 ZeroMemory(&findInfo
, sizeof(LVFINDINFOW
));
214 findInfo
.flags
= LVFI_STRING
;
215 findInfo
.psz
= ItemName
;
216 return ListView_FindItem(hDlgCtrl
, 0, &findInfo
);
220 InsertFileType(HWND hDlgCtrl
, WCHAR
* szName
, PINT iItem
, WCHAR
* szFile
)
222 PFOLDER_FILE_TYPE_ENTRY Entry
;
227 if (szName
[0] != L
'.')
229 /* FIXME handle URL protocol handlers */
233 /* allocate file type entry */
234 Entry
= (PFOLDER_FILE_TYPE_ENTRY
)HeapAlloc(GetProcessHeap(), 0, sizeof(FOLDER_FILE_TYPE_ENTRY
));
240 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, szName
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
243 /* FIXME check for duplicates */
245 /* query for the default key */
246 dwSize
= sizeof(Entry
->ClassKey
);
247 if (RegQueryValueExW(hKey
, NULL
, NULL
, NULL
, (LPBYTE
)Entry
->ClassKey
, &dwSize
) != ERROR_SUCCESS
)
249 /* no link available */
250 Entry
->ClassKey
[0] = 0;
253 if (Entry
->ClassKey
[0])
256 /* try open linked key */
257 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, Entry
->ClassKey
, 0, KEY_READ
, &hTemp
) == ERROR_SUCCESS
)
265 /* read friendly type name */
266 if (RegLoadMUIStringW(hKey
, L
"FriendlyTypeName", Entry
->FileDescription
, sizeof(Entry
->FileDescription
), NULL
, 0, NULL
) != ERROR_SUCCESS
)
268 /* read file description */
269 dwSize
= sizeof(Entry
->FileDescription
);
270 Entry
->FileDescription
[0] = 0;
272 /* read default key */
273 RegQueryValueExW(hKey
, NULL
, NULL
, NULL
, (LPBYTE
)Entry
->FileDescription
, &dwSize
);
279 /* convert extension to upper case */
280 wcscpy(Entry
->FileExtension
, szName
);
281 _wcsupr(Entry
->FileExtension
);
283 if (!Entry
->FileDescription
[0])
285 /* construct default 'FileExtensionFile' */
286 wcscpy(Entry
->FileDescription
, &Entry
->FileExtension
[1]);
287 wcscat(Entry
->FileDescription
, L
" ");
288 wcscat(Entry
->FileDescription
, szFile
);
291 ZeroMemory(&lvItem
, sizeof(LVITEMW
));
292 lvItem
.mask
= LVIF_TEXT
| LVIF_PARAM
;
294 lvItem
.pszText
= &Entry
->FileExtension
[1];
295 lvItem
.iItem
= *iItem
;
296 lvItem
.lParam
= (LPARAM
)Entry
;
297 (void)SendMessageW(hDlgCtrl
, LVM_INSERTITEMW
, 0, (LPARAM
)&lvItem
);
299 ZeroMemory(&lvItem
, sizeof(LVITEMW
));
300 lvItem
.mask
= LVIF_TEXT
;
301 lvItem
.pszText
= Entry
->FileDescription
;
302 lvItem
.iItem
= *iItem
;
305 (void)SendMessageW(hDlgCtrl
, LVM_SETITEMW
, 0, (LPARAM
)&lvItem
);
311 ListViewCompareProc(LPARAM lParam1
, LPARAM lParam2
, LPARAM lParamSort
)
313 PFOLDER_FILE_TYPE_ENTRY Entry1
, Entry2
;
315 Entry1
= (PFOLDER_FILE_TYPE_ENTRY
)lParam1
;
316 Entry2
= (PFOLDER_FILE_TYPE_ENTRY
)lParam2
;
318 return wcsicmp(Entry1
->FileExtension
, Entry2
->FileExtension
);
322 InitializeFileTypesListCtrl(HWND hwndDlg
)
332 hDlgCtrl
= GetDlgItem(hwndDlg
, 14000);
333 InitializeFileTypesListCtrlColumns(hDlgCtrl
);
336 if (!LoadStringW(shell32_hInstance
, IDS_SHV_COLUMN1
, szFile
, sizeof(szFile
) / sizeof(WCHAR
)))
338 /* default to english */
339 wcscpy(szFile
, L
"File");
341 szFile
[(sizeof(szFile
)/sizeof(WCHAR
))-1] = 0;
343 dwName
= sizeof(szName
) / sizeof(WCHAR
);
345 while(RegEnumKeyExW(HKEY_CLASSES_ROOT
, dwIndex
++, szName
, &dwName
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
347 InsertFileType(hDlgCtrl
, szName
, &iItem
, szFile
);
348 dwName
= sizeof(szName
) / sizeof(WCHAR
);
352 ListView_SortItems(hDlgCtrl
, ListViewCompareProc
, NULL
);
354 /* select first item */
355 ZeroMemory(&lvItem
, sizeof(LVITEMW
));
356 lvItem
.mask
= LVIF_STATE
;
357 lvItem
.stateMask
= (UINT
)-1;
358 lvItem
.state
= LVIS_FOCUSED
|LVIS_SELECTED
;
360 (void)SendMessageW(hDlgCtrl
, LVM_SETITEMW
, 0, (LPARAM
)&lvItem
);
365 PFOLDER_FILE_TYPE_ENTRY
372 Count
= ListView_GetItemCount(hDlgCtrl
);
374 for (Index
= 0; Index
< Count
; Index
++)
376 ZeroMemory(&lvItem
, sizeof(LVITEM
));
377 lvItem
.mask
= LVIF_PARAM
| LVIF_STATE
;
378 lvItem
.iItem
= Index
;
379 lvItem
.stateMask
= (UINT
)-1;
381 if (ListView_GetItem(hDlgCtrl
, &lvItem
))
383 if (lvItem
.state
& LVIS_SELECTED
)
384 return (PFOLDER_FILE_TYPE_ENTRY
)lvItem
.lParam
;
394 FolderOptionsFileTypesDlg(
402 WCHAR Buffer
[255], FormatBuffer
[255];
403 PFOLDER_FILE_TYPE_ENTRY pItem
;
409 InitializeFileTypesListCtrl(hwndDlg
);
412 switch(LOWORD(wParam
))
415 pItem
= FindSelectedItem(GetDlgItem(hwndDlg
, 14000));
418 Info
.oaifInFlags
= OAIF_ALLOW_REGISTRATION
| OAIF_REGISTER_EXT
;
419 Info
.pcszClass
= pItem
->FileExtension
;
420 SHOpenWithDialog(hwndDlg
, &Info
);
427 lppl
= (LPNMLISTVIEW
) lParam
;
429 if (lppl
->hdr
.code
== LVN_ITEMCHANGING
)
431 ZeroMemory(&lvItem
, sizeof(LVITEM
));
432 lvItem
.mask
= LVIF_PARAM
;
433 lvItem
.iItem
= lppl
->iItem
;
434 if (!SendMessageW(lppl
->hdr
.hwndFrom
, LVM_GETITEMW
, 0, (LPARAM
)&lvItem
))
437 pItem
= (PFOLDER_FILE_TYPE_ENTRY
)lvItem
.lParam
;
441 if (!(lppl
->uOldState
& LVIS_FOCUSED
) && (lppl
->uNewState
& LVIS_FOCUSED
))
443 /* new focused item */
444 if (!LoadStringW(shell32_hInstance
, IDS_FILE_DETAILS
, FormatBuffer
, sizeof(FormatBuffer
) / sizeof(WCHAR
)))
446 /* use default english format string */
447 wcscpy(FormatBuffer
, L
"Details for '%s' extension");
451 swprintf(Buffer
, FormatBuffer
, &pItem
->FileExtension
[1]);
453 SendDlgItemMessageW(hwndDlg
, 14003, WM_SETTEXT
, 0, (LPARAM
)Buffer
);
455 if (!LoadStringW(shell32_hInstance
, IDS_FILE_DETAILSADV
, FormatBuffer
, sizeof(FormatBuffer
) / sizeof(WCHAR
)))
457 /* use default english format string */
458 wcscpy(FormatBuffer
, L
"Files with extension '%s' are of type '%s'. To change settings that affect all '%s' files, click Advanced.");
461 swprintf(Buffer
, FormatBuffer
, &pItem
->FileExtension
[1], &pItem
->FileDescription
[0], &pItem
->FileDescription
[0]);
463 SendDlgItemMessageW(hwndDlg
, 14007, WM_SETTEXT
, 0, (LPARAM
)Buffer
);
474 ShowFolderOptionsDialog(HWND hWnd
, HINSTANCE hInst
)
476 PROPSHEETHEADERW pinfo
;
477 HPROPSHEETPAGE hppages
[3];
478 HPROPSHEETPAGE hpage
;
480 WCHAR szOptions
[100];
482 hpage
= SH_CreatePropertySheetPage("FOLDER_OPTIONS_GENERAL_DLG", FolderOptionsGeneralDlg
, 0, NULL
);
484 hppages
[num_pages
++] = hpage
;
486 hpage
= SH_CreatePropertySheetPage("FOLDER_OPTIONS_VIEW_DLG", FolderOptionsViewDlg
, 0, NULL
);
488 hppages
[num_pages
++] = hpage
;
490 hpage
= SH_CreatePropertySheetPage("FOLDER_OPTIONS_FILETYPES_DLG", FolderOptionsFileTypesDlg
, 0, NULL
);
492 hppages
[num_pages
++] = hpage
;
494 szOptions
[0] = L
'\0';
495 LoadStringW(shell32_hInstance
, IDS_FOLDER_OPTIONS
, szOptions
, sizeof(szOptions
) / sizeof(WCHAR
));
496 szOptions
[(sizeof(szOptions
)/sizeof(WCHAR
))-1] = L
'\0';
498 memset(&pinfo
, 0x0, sizeof(PROPSHEETHEADERW
));
499 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
500 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
;
501 pinfo
.nPages
= num_pages
;
502 pinfo
.u3
.phpage
= hppages
;
503 pinfo
.pszCaption
= szOptions
;
505 PropertySheetW(&pinfo
);
509 Options_RunDLLCommon(HWND hWnd
, HINSTANCE hInst
, int fOptions
, DWORD nCmdShow
)
514 ShowFolderOptionsDialog(hWnd
, hInst
);
517 // show taskbar options dialog
518 FIXME("notify explorer to show taskbar options dialog");
519 //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0);
522 FIXME("unrecognized options id %d\n", fOptions
);
526 /*************************************************************************
527 * Options_RunDLL (SHELL32.@)
529 VOID WINAPI
Options_RunDLL(HWND hWnd
, HINSTANCE hInst
, LPCSTR cmd
, DWORD nCmdShow
)
531 Options_RunDLLCommon(hWnd
, hInst
, StrToIntA(cmd
), nCmdShow
);
533 /*************************************************************************
534 * Options_RunDLLA (SHELL32.@)
536 VOID WINAPI
Options_RunDLLA(HWND hWnd
, HINSTANCE hInst
, LPCSTR cmd
, DWORD nCmdShow
)
538 Options_RunDLLCommon(hWnd
, hInst
, StrToIntA(cmd
), nCmdShow
);
541 /*************************************************************************
542 * Options_RunDLLW (SHELL32.@)
544 VOID WINAPI
Options_RunDLLW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR cmd
, DWORD nCmdShow
)
546 Options_RunDLLCommon(hWnd
, hInst
, StrToIntW(cmd
), nCmdShow
);
551 CountFolderAndFiles(LPVOID lParam
)
553 WIN32_FIND_DATAW FindData
;
558 PFOLDER_PROPERTIES_CONTEXT pContext
= (PFOLDER_PROPERTIES_CONTEXT
) lParam
;
560 pOffset
= PathAddBackslashW(pContext
->szFolderPath
);
564 Length
= pOffset
- pContext
->szFolderPath
;
566 wcscpy(pOffset
, L
"*.*");
567 hFile
= FindFirstFileW(pContext
->szFolderPath
, &FindData
);
568 if (hFile
== INVALID_HANDLE_VALUE
)
573 ret
= FindNextFileW(hFile
, &FindData
);
576 if (FindData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
578 if (FindData
.cFileName
[0] == L
'.' && FindData
.cFileName
[1] == L
'.' &&
579 FindData
.cFileName
[2] == L
'\0')
583 wcscpy(pOffset
, FindData
.cFileName
);
584 CountFolderAndFiles((LPVOID
)pContext
);
590 pContext
->bSize
.u
.LowPart
+= FindData
.nFileSizeLow
;
591 pContext
->bSize
.u
.HighPart
+= FindData
.nFileSizeHigh
;
594 else if (GetLastError() == ERROR_NO_MORE_FILES
)
606 InitializeFolderGeneralDlg(PFOLDER_PROPERTIES_CONTEXT pContext
)
609 WIN32_FILE_ATTRIBUTE_DATA FolderAttribute
;
612 WCHAR szBuffer
[MAX_PATH
+5];
613 WCHAR szFormat
[30] = {0};
615 static const WCHAR wFormat
[] = {'%','0','2','d','/','%','0','2','d','/','%','0','4','d',' ',' ','%','0','2','d',':','%','0','2','u',0};
617 pFolderName
= wcsrchr(pContext
->szFolderPath
, L
'\\');
621 /* set folder name */
622 SendDlgItemMessageW(pContext
->hwndDlg
, 14001, WM_SETTEXT
, 0, (LPARAM
) (pFolderName
+ 1));
623 /* set folder location */
624 pFolderName
[0] = L
'\0';
625 if (wcslen(pContext
->szFolderPath
) == 2)
627 /* folder is located at root */
628 WCHAR szDrive
[4] = {L
'C',L
':',L
'\\',L
'\0'};
629 szDrive
[0] = pContext
->szFolderPath
[0];
630 SendDlgItemMessageW(pContext
->hwndDlg
, 14007, WM_SETTEXT
, 0, (LPARAM
) szDrive
);
634 SendDlgItemMessageW(pContext
->hwndDlg
, 14007, WM_SETTEXT
, 0, (LPARAM
) pContext
->szFolderPath
);
636 pFolderName
[0] = L
'\\';
637 /* get folder properties */
638 if (GetFileAttributesExW(pContext
->szFolderPath
, GetFileExInfoStandard
, (LPVOID
)&FolderAttribute
))
640 if (FolderAttribute
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
)
642 /* check readonly button */
643 SendDlgItemMessage(pContext
->hwndDlg
, 14021, BM_SETCHECK
, BST_CHECKED
, 0);
646 if (FolderAttribute
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
)
648 /* check hidden button */
649 SendDlgItemMessage(pContext
->hwndDlg
, 14022, BM_SETCHECK
, BST_CHECKED
, 0);
652 if (FileTimeToLocalFileTime(&FolderAttribute
.ftCreationTime
, &ft
))
654 FileTimeToSystemTime(&ft
, &dt
);
655 swprintf (szBuffer
, wFormat
, dt
.wDay
, dt
.wMonth
, dt
.wYear
, dt
.wHour
, dt
.wMinute
);
656 SendDlgItemMessageW(pContext
->hwndDlg
, 14015, WM_SETTEXT
, 0, (LPARAM
) szBuffer
);
659 /* now enumerate enumerate contents */
660 wcscpy(szBuffer
, pContext
->szFolderPath
);
661 CountFolderAndFiles((LPVOID
)pContext
);
662 wcscpy(pContext
->szFolderPath
, szBuffer
);
663 /* set folder details */
664 LoadStringW(shell32_hInstance
, IDS_FILE_FOLDER
, szFormat
, sizeof(szFormat
)/sizeof(WCHAR
));
665 szFormat
[(sizeof(szFormat
)/sizeof(WCHAR
))-1] = L
'\0';
666 swprintf(szBuffer
, szFormat
, pContext
->cFiles
, pContext
->cFolder
);
667 SendDlgItemMessageW(pContext
->hwndDlg
, 14011, WM_SETTEXT
, 0, (LPARAM
) szBuffer
);
669 if (StrFormatByteSizeW(pContext
->bSize
.QuadPart
, szBuffer
, sizeof(szBuffer
)/sizeof(WCHAR
)))
671 /* store folder size */
672 SendDlgItemMessageW(pContext
->hwndDlg
, 14009, WM_SETTEXT
, 0, (LPARAM
) szBuffer
);
679 FolderPropertiesGeneralDlg(
686 LPPROPSHEETPAGEW ppsp
;
687 PFOLDER_PROPERTIES_CONTEXT pContext
;
689 WIN32_FILE_ATTRIBUTE_DATA FolderAttribute
;
697 ppsp
= (LPPROPSHEETPAGEW
)lParam
;
700 hIcon
= LoadIconW(shell32_hInstance
, MAKEINTRESOURCEW(IDI_SHELL_FOLDER_OPEN
));
702 SendDlgItemMessageW(hwndDlg
, 14000, STM_SETICON
, (WPARAM
)hIcon
, 0);
704 pContext
= SHAlloc(sizeof(FOLDER_PROPERTIES_CONTEXT
));
707 ZeroMemory(pContext
, sizeof(FOLDER_PROPERTIES_CONTEXT
));
708 pContext
->hwndDlg
= hwndDlg
;
709 wcscpy(pContext
->szFolderPath
, (LPWSTR
)ppsp
->lParam
);
710 SetWindowLongPtr(hwndDlg
, DWL_USER
, (LONG_PTR
)pContext
);
711 InitializeFolderGeneralDlg(pContext
);
715 if (HIWORD(wParam
) == BN_CLICKED
)
717 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
721 pContext
= (PFOLDER_PROPERTIES_CONTEXT
)GetWindowLongPtr(hwndDlg
, DWL_USER
);
722 SHFree((LPVOID
)pContext
);
725 pContext
= (PFOLDER_PROPERTIES_CONTEXT
)GetWindowLongPtr(hwndDlg
, DWL_USER
);
726 lppsn
= (LPPSHNOTIFY
) lParam
;
727 if (lppsn
->hdr
.code
== PSN_APPLY
)
729 if (GetFileAttributesExW(pContext
->szFolderPath
, GetFileExInfoStandard
, (LPVOID
)&FolderAttribute
))
731 res
= SendDlgItemMessageW(hwndDlg
, 14021, BM_GETCHECK
, 0, 0);
732 if (res
== BST_CHECKED
)
733 FolderAttribute
.dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
735 FolderAttribute
.dwFileAttributes
&= (~FILE_ATTRIBUTE_READONLY
);
737 res
= SendDlgItemMessageW(hwndDlg
, 14022, BM_GETCHECK
, 0, 0);
738 if (res
== BST_CHECKED
)
739 FolderAttribute
.dwFileAttributes
|= FILE_ATTRIBUTE_HIDDEN
;
741 FolderAttribute
.dwFileAttributes
&= (~FILE_ATTRIBUTE_HIDDEN
);
743 Attribute
= FolderAttribute
.dwFileAttributes
&
744 (FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_NORMAL
|FILE_ATTRIBUTE_READONLY
|FILE_ATTRIBUTE_SYSTEM
|FILE_ATTRIBUTE_TEMPORARY
);
746 SetFileAttributesW(pContext
->szFolderPath
, Attribute
);
748 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
759 FolderAddPropSheetPageProc(HPROPSHEETPAGE hpage
, LPARAM lParam
)
761 PROPSHEETHEADERW
*ppsh
= (PROPSHEETHEADERW
*)lParam
;
762 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_PROPERTY_SHEET_PAGE
)
764 ppsh
->u3
.phpage
[ppsh
->nPages
++] = hpage
;
771 SH_ShowFolderProperties(LPWSTR pwszFolder
, LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST
* apidl
)
773 HPROPSHEETPAGE hppages
[MAX_PROPERTY_SHEET_PAGE
];
774 HPROPSHEETPAGE hpage
;
775 PROPSHEETHEADERW psh
;
777 WCHAR szName
[MAX_PATH
] = {0};
780 IDataObject
* pDataObj
= NULL
;
782 if (!PathIsDirectoryW(pwszFolder
))
785 pFolderName
= wcsrchr(pwszFolder
, L
'\\');
789 wcscpy(szName
, pFolderName
+ 1);
791 hpage
= SH_CreatePropertySheetPage("SHELL_FOLDER_GENERAL_DLG", FolderPropertiesGeneralDlg
, (LPARAM
)pwszFolder
, NULL
);
795 ZeroMemory(&psh
, sizeof(PROPSHEETHEADERW
));
796 hppages
[psh
.nPages
] = hpage
;
798 psh
.dwSize
= sizeof(PROPSHEETHEADERW
);
799 psh
.dwFlags
= PSH_PROPTITLE
;
800 psh
.hwndParent
= NULL
;
801 psh
.u3
.phpage
= hppages
;
802 psh
.pszCaption
= szName
;
805 if (SHCreateDataObject(pidlFolder
, 1, apidl
, NULL
, &IID_IDataObject
, (void**)&pDataObj
) == S_OK
)
807 hpsx
= SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT
, L
"Directory", MAX_PROPERTY_SHEET_PAGE
-1, pDataObj
);
810 SHAddFromPropSheetExtArray(hpsx
,
811 (LPFNADDPROPSHEETPAGE
)FolderAddPropSheetPageProc
,
816 ret
= PropertySheetW(&psh
);
818 IDataObject_Release(pDataObj
);
821 SHDestroyPropSheetExtArray(hpsx
);