2011-05-15 15:55:49 +00:00
|
|
|
/*
|
|
|
|
* Shell Library Functions
|
|
|
|
*
|
|
|
|
* Copyright 2005 Johannes Anderwald
|
2012-01-11 20:20:01 +00:00
|
|
|
* Copyright 2012 Rafal Harabien
|
2018-12-02 19:25:46 +00:00
|
|
|
* Copyright 2017-2018 Katayama Hirofumi MZ
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-11 20:20:01 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
|
|
|
|
|
2012-01-11 14:13:14 +00:00
|
|
|
static UINT
|
|
|
|
LoadPropSheetHandlers(LPCWSTR pwszPath, PROPSHEETHEADERW *pHeader, UINT cMaxPages, HPSXA *phpsxa, IDataObject *pDataObj)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2012-01-11 14:13:14 +00:00
|
|
|
WCHAR wszBuf[MAX_PATH];
|
|
|
|
UINT cPages = 0, i = 0;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-11 14:13:14 +00:00
|
|
|
LPWSTR pwszFilename = PathFindFileNameW(pwszPath);
|
2012-01-13 23:41:09 +00:00
|
|
|
BOOL bDir = PathIsDirectoryW(pwszPath);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-13 23:41:09 +00:00
|
|
|
if (bDir)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2012-01-13 23:41:09 +00:00
|
|
|
phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Folder", cMaxPages - cPages, pDataObj);
|
|
|
|
cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader);
|
|
|
|
|
|
|
|
phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Directory", cMaxPages - cPages, pDataObj);
|
2012-01-11 14:13:14 +00:00
|
|
|
cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-11 14:13:14 +00:00
|
|
|
/* Load property sheet handlers from ext key */
|
|
|
|
LPWSTR pwszExt = PathFindExtensionW(pwszFilename);
|
|
|
|
phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, pwszExt, cMaxPages - cPages, pDataObj);
|
|
|
|
cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader);
|
|
|
|
|
|
|
|
/* Load property sheet handlers from prog id key */
|
|
|
|
DWORD cbBuf = sizeof(wszBuf);
|
|
|
|
if (RegGetValueW(HKEY_CLASSES_ROOT, pwszExt, L"", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2012-01-11 14:13:14 +00:00
|
|
|
TRACE("EnumPropSheetExt wszBuf %s, pwszExt %s\n", debugstr_w(wszBuf), debugstr_w(pwszExt));
|
|
|
|
phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszBuf, cMaxPages - cPages, pDataObj);
|
|
|
|
cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
2012-01-13 23:41:09 +00:00
|
|
|
/* Add property sheet handlers from "*" key */
|
|
|
|
phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"*", cMaxPages - cPages, pDataObj);
|
|
|
|
cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader);
|
|
|
|
}
|
2012-01-11 14:13:14 +00:00
|
|
|
|
|
|
|
return cPages;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* SH_ShowPropertiesDialog
|
|
|
|
*
|
|
|
|
* called from ShellExecuteExW32
|
|
|
|
*
|
2012-01-10 16:53:46 +00:00
|
|
|
* pwszPath contains path of folder/file
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* TODO: provide button change application type if file has registered type
|
|
|
|
* make filename field editable and apply changes to filename on close
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL
|
2016-11-17 14:35:19 +00:00
|
|
|
SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2012-01-11 14:13:14 +00:00
|
|
|
HPSXA hpsxa[3] = {NULL, NULL, NULL};
|
2012-01-11 21:58:47 +00:00
|
|
|
CComObject<CFileDefExt> *pFileDefExt = NULL;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-10 16:01:13 +00:00
|
|
|
TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(pwszPath));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-10 16:53:46 +00:00
|
|
|
if (pwszPath == NULL || !wcslen(pwszPath))
|
2011-05-15 15:55:49 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2012-01-15 19:45:02 +00:00
|
|
|
HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
|
2011-05-15 15:55:49 +00:00
|
|
|
memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE);
|
|
|
|
|
2012-01-10 16:53:46 +00:00
|
|
|
/* Make a copy of path */
|
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
StringCbCopyW(wszPath, sizeof(wszPath), pwszPath);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-10 19:57:53 +00:00
|
|
|
/* remove trailing \\ at the end of path */
|
|
|
|
PathRemoveBackslashW(wszPath);
|
2011-10-17 13:22:20 +00:00
|
|
|
|
2012-01-10 19:57:53 +00:00
|
|
|
/* Handle drives */
|
2012-01-10 16:53:46 +00:00
|
|
|
if (PathIsRootW(wszPath))
|
2017-11-25 09:27:20 +00:00
|
|
|
return SUCCEEDED(SH_ShowDriveProperties(wszPath, pidlFolder, apidl));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2018-12-02 19:25:46 +00:00
|
|
|
DWORD style = WS_DISABLED | WS_CLIPSIBLINGS | WS_CAPTION;
|
|
|
|
DWORD exstyle = WS_EX_WINDOWEDGE | WS_EX_APPWINDOW;
|
|
|
|
CStubWindow32 stub;
|
|
|
|
if (!stub.Create(NULL, NULL, NULL, style, exstyle))
|
2018-12-02 20:38:36 +00:00
|
|
|
{
|
|
|
|
ERR("StubWindow32 creation failed\n");
|
2018-12-02 20:43:21 +00:00
|
|
|
return FALSE;
|
2018-12-02 20:38:36 +00:00
|
|
|
}
|
2018-12-02 19:25:46 +00:00
|
|
|
|
2012-01-13 23:41:09 +00:00
|
|
|
/* Handle files and folders */
|
2012-01-11 14:13:14 +00:00
|
|
|
PROPSHEETHEADERW Header;
|
|
|
|
memset(&Header, 0x0, sizeof(PROPSHEETHEADERW));
|
|
|
|
Header.dwSize = sizeof(PROPSHEETHEADERW);
|
2018-12-02 19:25:46 +00:00
|
|
|
Header.hwndParent = stub;
|
2012-01-11 14:13:14 +00:00
|
|
|
Header.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE;
|
|
|
|
Header.phpage = hppages;
|
|
|
|
Header.pszCaption = PathFindFileNameW(wszPath);
|
|
|
|
|
|
|
|
CComPtr<IDataObject> pDataObj;
|
2013-11-11 16:42:16 +00:00
|
|
|
HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2012-01-11 14:13:14 +00:00
|
|
|
if (SUCCEEDED(hr))
|
2012-01-11 20:20:01 +00:00
|
|
|
{
|
2012-01-15 19:45:02 +00:00
|
|
|
hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt);
|
|
|
|
if (SUCCEEDED(hr))
|
2012-01-11 20:20:01 +00:00
|
|
|
{
|
2012-01-15 19:45:02 +00:00
|
|
|
pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count
|
2012-01-11 20:20:01 +00:00
|
|
|
hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("AddPages failed\n");
|
|
|
|
} else
|
|
|
|
ERR("Initialize failed\n");
|
|
|
|
}
|
|
|
|
|
2012-01-11 14:13:14 +00:00
|
|
|
LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj);
|
2012-01-11 20:20:01 +00:00
|
|
|
}
|
2012-01-11 14:13:14 +00:00
|
|
|
|
|
|
|
INT_PTR Result = PropertySheetW(&Header);
|
|
|
|
|
|
|
|
for (UINT i = 0; i < 3; ++i)
|
|
|
|
if (hpsxa[i])
|
|
|
|
SHDestroyPropSheetExtArray(hpsxa[i]);
|
2012-01-11 21:58:47 +00:00
|
|
|
if (pFileDefExt)
|
|
|
|
pFileDefExt->Release();
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2018-12-02 19:25:46 +00:00
|
|
|
stub.DestroyWindow();
|
|
|
|
|
2012-01-11 14:13:14 +00:00
|
|
|
return (Result != -1);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*EOF */
|