Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenfprop.cpp
Go to the documentation of this file.
00001 /* 00002 * Shell Library Functions 00003 * 00004 * Copyright 2005 Johannes Anderwald 00005 * Copyright 2012 Rafal Harabien 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #include <precomp.h> 00023 00024 #define MAX_PROPERTY_SHEET_PAGE 32 00025 00026 WINE_DEFAULT_DEBUG_CHANNEL(shell); 00027 00028 EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj); 00029 00030 static BOOL CALLBACK 00031 AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam) 00032 { 00033 PROPSHEETHEADERW *pHeader = (PROPSHEETHEADERW *)lParam; 00034 00035 if (pHeader->nPages < MAX_PROPERTY_SHEET_PAGE) 00036 { 00037 pHeader->phpage[pHeader->nPages++] = hPage; 00038 return TRUE; 00039 } 00040 00041 return FALSE; 00042 } 00043 00044 static UINT 00045 LoadPropSheetHandlers(LPCWSTR pwszPath, PROPSHEETHEADERW *pHeader, UINT cMaxPages, HPSXA *phpsxa, IDataObject *pDataObj) 00046 { 00047 WCHAR wszBuf[MAX_PATH]; 00048 UINT cPages = 0, i = 0; 00049 00050 LPWSTR pwszFilename = PathFindFileNameW(pwszPath); 00051 BOOL bDir = PathIsDirectoryW(pwszPath); 00052 00053 if (bDir) 00054 { 00055 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Folder", cMaxPages - cPages, pDataObj); 00056 cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader); 00057 00058 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Directory", cMaxPages - cPages, pDataObj); 00059 cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader); 00060 } 00061 else 00062 { 00063 /* Load property sheet handlers from ext key */ 00064 LPWSTR pwszExt = PathFindExtensionW(pwszFilename); 00065 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, pwszExt, cMaxPages - cPages, pDataObj); 00066 cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader); 00067 00068 /* Load property sheet handlers from prog id key */ 00069 DWORD cbBuf = sizeof(wszBuf); 00070 if (RegGetValueW(HKEY_CLASSES_ROOT, pwszExt, L"", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS) 00071 { 00072 TRACE("EnumPropSheetExt wszBuf %s, pwszExt %s\n", debugstr_w(wszBuf), debugstr_w(pwszExt)); 00073 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszBuf, cMaxPages - cPages, pDataObj); 00074 cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader); 00075 } 00076 00077 /* Add property sheet handlers from "*" key */ 00078 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"*", cMaxPages - cPages, pDataObj); 00079 cPages += SHAddFromPropSheetExtArray(phpsxa[i++], AddPropSheetPageCallback, (LPARAM)pHeader); 00080 } 00081 00082 return cPages; 00083 } 00084 00085 /************************************************************************* 00086 * 00087 * SH_ShowPropertiesDialog 00088 * 00089 * called from ShellExecuteExW32 00090 * 00091 * pwszPath contains path of folder/file 00092 * 00093 * TODO: provide button change application type if file has registered type 00094 * make filename field editable and apply changes to filename on close 00095 */ 00096 00097 BOOL 00098 SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl) 00099 { 00100 HPSXA hpsxa[3] = {NULL, NULL, NULL}; 00101 CComObject<CFileDefExt> *pFileDefExt = NULL; 00102 00103 TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(pwszPath)); 00104 00105 if (pwszPath == NULL || !wcslen(pwszPath)) 00106 return FALSE; 00107 00108 HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE]; 00109 memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE); 00110 00111 /* Make a copy of path */ 00112 WCHAR wszPath[MAX_PATH]; 00113 StringCbCopyW(wszPath, sizeof(wszPath), pwszPath); 00114 00115 /* remove trailing \\ at the end of path */ 00116 PathRemoveBackslashW(wszPath); 00117 00118 /* Handle drives */ 00119 if (PathIsRootW(wszPath)) 00120 return SH_ShowDriveProperties(wszPath, pidlFolder, apidl); 00121 00122 /* Handle files and folders */ 00123 PROPSHEETHEADERW Header; 00124 memset(&Header, 0x0, sizeof(PROPSHEETHEADERW)); 00125 Header.dwSize = sizeof(PROPSHEETHEADERW); 00126 Header.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE; 00127 Header.phpage = hppages; 00128 Header.pszCaption = PathFindFileNameW(wszPath); 00129 00130 CComPtr<IDataObject> pDataObj; 00131 HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj); 00132 00133 if (SUCCEEDED(hr)) 00134 { 00135 hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt); 00136 if (SUCCEEDED(hr)) 00137 { 00138 pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count 00139 hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL); 00140 if (SUCCEEDED(hr)) 00141 { 00142 hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header); 00143 if (FAILED(hr)) 00144 ERR("AddPages failed\n"); 00145 } else 00146 ERR("Initialize failed\n"); 00147 } 00148 00149 LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj); 00150 } 00151 00152 INT_PTR Result = PropertySheetW(&Header); 00153 00154 for (UINT i = 0; i < 3; ++i) 00155 if (hpsxa[i]) 00156 SHDestroyPropSheetExtArray(hpsxa[i]); 00157 if (pFileDefExt) 00158 pFileDefExt->Release(); 00159 00160 return (Result != -1); 00161 } 00162 00163 /*EOF */ Generated on Sat May 26 2012 04:25:00 for ReactOS by
1.7.6.1
|