ReactOS 0.4.15-dev-5667-ged97270
fprop.cpp
Go to the documentation of this file.
1/*
2 * Shell Library Functions
3 *
4 * Copyright 2005 Johannes Anderwald
5 * Copyright 2012 Rafal Harabien
6 * Copyright 2017-2018 Katayama Hirofumi MZ
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "precomp.h"
24
26
28
29static UINT
30LoadPropSheetHandlers(LPCWSTR pwszPath, PROPSHEETHEADERW *pHeader, UINT cMaxPages, HPSXA *phpsxa, IDataObject *pDataObj)
31{
32 WCHAR wszBuf[MAX_PATH];
33 UINT cPages = 0, i = 0;
34
35 LPWSTR pwszFilename = PathFindFileNameW(pwszPath);
36 BOOL bDir = PathIsDirectoryW(pwszPath);
37
38 if (bDir)
39 {
40 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Folder", cMaxPages - cPages, pDataObj);
42
43 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Directory", cMaxPages - cPages, pDataObj);
45 }
46 else
47 {
48 /* Load property sheet handlers from ext key */
49 LPWSTR pwszExt = PathFindExtensionW(pwszFilename);
50 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, pwszExt, cMaxPages - cPages, pDataObj);
52
53 /* Load property sheet handlers from prog id key */
54 DWORD cbBuf = sizeof(wszBuf);
55 if (RegGetValueW(HKEY_CLASSES_ROOT, pwszExt, L"", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS)
56 {
57 TRACE("EnumPropSheetExt wszBuf %s, pwszExt %s\n", debugstr_w(wszBuf), debugstr_w(pwszExt));
58 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszBuf, cMaxPages - cPages, pDataObj);
60 }
61
62 /* Add property sheet handlers from "*" key */
63 phpsxa[i] = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"*", cMaxPages - cPages, pDataObj);
65 }
66
67 return cPages;
68}
69
70/*************************************************************************
71 *
72 * SH_ShowPropertiesDialog
73 *
74 * called from ShellExecuteExW32
75 *
76 * pwszPath contains path of folder/file
77 *
78 * TODO: provide button change application type if file has registered type
79 * make filename field editable and apply changes to filename on close
80 */
81
82BOOL
84{
85 HPSXA hpsxa[3] = {NULL, NULL, NULL};
86 CComObject<CFileDefExt> *pFileDefExt = NULL;
87
88 TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(pwszPath));
89
90 if (pwszPath == NULL || !wcslen(pwszPath))
91 return FALSE;
92
94 memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE);
95
96 /* Make a copy of path */
97 WCHAR wszPath[MAX_PATH];
98 StringCbCopyW(wszPath, sizeof(wszPath), pwszPath);
99
100 /* remove trailing \\ at the end of path */
101 PathRemoveBackslashW(wszPath);
102
103 CDataObjectHIDA cida(pDataObj);
104 if (FAILED_UNEXPECTEDLY(cida.hr()))
105 return FALSE;
106
107 if (cida->cidl == 0)
108 {
109 ERR("Empty HIDA\n");
110 return FALSE;
111 }
112
113 /* Handle drives */
114 if (_ILIsDrive(HIDA_GetPIDLItem(cida, 0)))
115 return SH_ShowDriveProperties(wszPath, pDataObj);
116
117
118 RECT rcPosition = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0};
119 POINT pt;
120 if (SUCCEEDED(DataObject_GetOffset(pDataObj, &pt)))
121 {
122 rcPosition.left = pt.x;
123 rcPosition.top = pt.y;
124 }
125
129 if (!stub.Create(NULL, rcPosition, NULL, style, exstyle))
130 {
131 ERR("StubWindow32 creation failed\n");
132 return FALSE;
133 }
134
135 /* Handle files and folders */
137 memset(&Header, 0x0, sizeof(PROPSHEETHEADERW));
138 Header.dwSize = sizeof(PROPSHEETHEADERW);
139 Header.hwndParent = stub;
140 Header.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE;
141 Header.phpage = hppages;
142 Header.pszCaption = PathFindFileNameW(wszPath);
143
144 HRESULT hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt);
145 if (SUCCEEDED(hr))
146 {
147 pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count
148 hr = pFileDefExt->Initialize(HIDA_GetPIDLFolder(cida), pDataObj, NULL);
150 {
151 hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header);
153 {
154 ERR("AddPages failed\n");
155 return FALSE;
156 }
157 }
158 else
159 {
160 ERR("Initialize failed\n");
161 return FALSE;
162 }
163 }
164
165 LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj);
166
168
169 for (UINT i = 0; i < 3; ++i)
170 if (hpsxa[i])
172 if (pFileDefExt)
173 pFileDefExt->Release();
174
175 stub.DestroyWindow();
176
177 return (Result != -1);
178}
179
180/*EOF */
Arabic default style
Definition: afstyles.h:94
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define EXTERN_C
Definition: basetyps.h:12
#define ERR(fmt,...)
Definition: debug.h:110
Definition: Header.h:9
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2905
#define MAX_PATH
Definition: compat.h:34
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:129
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1722
#define pt(x, y)
Definition: drawing.c:79
BOOL SH_ShowDriveProperties(WCHAR *pwszDrive, IDataObject *pDataObj)
Definition: drive.cpp:170
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
static UINT LoadPropSheetHandlers(LPCWSTR pwszPath, PROPSHEETHEADERW *pHeader, UINT cMaxPages, HPSXA *phpsxa, IDataObject *pDataObj)
Definition: fprop.cpp:30
BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, IDataObject *pDataObj)
Definition: fprop.cpp:83
FxAutoRegKey hKey
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
FxContextHeader * pHeader
Definition: handleapi.cpp:604
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define WS_CAPTION
Definition: pedump.c:624
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
BOOL _ILIsDrive(LPCITEMIDLIST pidl)
Definition: pidl.c:1964
#define PSH_PROPTITLE
Definition: prsht.h:40
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define memset(x, y, z)
Definition: compat.h:39
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2150
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1973
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:569
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:564
#define MAX_PROPERTY_SHEET_PAGE
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
Definition: stubgen.c:11
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
struct _stub stub
int32_t INT_PTR
Definition: typedefs.h:64
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define CW_USEDEFAULT
Definition: winuser.h:225
_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
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185