[SHELL32] SHMultiFileProperties workaround and minimal SHObjectProperties (#7025)
authorWhindmar Saksit <whindsaks@proton.me>
Fri, 21 Jun 2024 14:26:52 +0000 (16:26 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2024 14:26:52 +0000 (16:26 +0200)
dll/win32/shell32/shlfolder.cpp
dll/win32/shell32/stubs.cpp
dll/win32/shell32/wine/shellord.c

index 45829ea..a99f822 100644 (file)
@@ -500,7 +500,7 @@ SHELL32_ShowPropertiesDialog(IDataObject *pdtobj)
         return E_INVALIDARG;
 
     pdtobj->AddRef();
-    if (!SHCreateThread(_ShowPropertiesDialogThread, pdtobj, CTF_INSIST | CTF_COINIT, NULL))
+    if (!SHCreateThread(_ShowPropertiesDialogThread, pdtobj, CTF_INSIST | CTF_COINIT | CTF_PROCESS_REF, NULL))
     {
         pdtobj->Release();
         return HResultFromWin32(GetLastError());
index c66355e..6b6e141 100644 (file)
@@ -128,6 +128,15 @@ SHParseDarwinIDFromCacheW(LPCWSTR lpUnknown1, LPWSTR lpUnknown2)
     return E_FAIL;
 }
 
+static HRESULT DataObject_GetHIDACount(IDataObject *pdo)
+{
+    if (!pdo)
+        return E_INVALIDARG;
+    CDataObjectHIDA cida(pdo);
+    HRESULT hr = cida.hr();
+    return SUCCEEDED(hr) ? cida->cidl : hr;
+}
+
 /*
  * Unimplemented
  */
@@ -136,6 +145,19 @@ WINAPI
 SHMultiFileProperties(IDataObject *pDataObject, DWORD dwFlags)
 {
     FIXME("SHMultiFileProperties() stub\n");
+
+    // Temporary workaround to display a property sheet if possible
+    if (DataObject_GetHIDACount(pDataObject) == 1)
+        return SHELL32_ShowPropertiesDialog(pDataObject);
+
+    if (pDataObject)
+    {
+        HWND hWnd;
+        if (FAILED(IUnknown_GetWindow(pDataObject, &hWnd))) // Will probably not work but we have no other option
+            hWnd = NULL;
+        SHELL_ErrorBox(hWnd, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
+    }  
+
     return E_FAIL;
 }
 
index b02da92..de16bbe 100644 (file)
@@ -2314,6 +2314,22 @@ INT WINAPI SHHandleUpdateImage(PCIDLIST_ABSOLUTE pidlExtra)
 
 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
 {
+    LPITEMIDLIST pidl = NULL;
+    switch (dwType)
+    {
+        case SHOP_FILEPATH:
+            pidl = ILCreateFromPathW(szObject);
+            break;
+    }
+    if (pidl)
+    {
+        SHELLEXECUTEINFOW sei = { sizeof(sei), SEE_MASK_INVOKEIDLIST, hwnd, L"properties",
+                                  NULL, szPage, NULL, SW_SHOWNORMAL, NULL, pidl };
+        BOOL result = ShellExecuteExW(&sei);
+        ILFree(pidl);
+        return result;
+    }
+
     FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
 
     return TRUE;