[SHELL32] CDefView: Implement SFVM_GETCOMMANDIR callback (#6941)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Sun, 26 May 2024 22:01:51 +0000 (07:01 +0900)
committerGitHub <noreply@github.com>
Sun, 26 May 2024 22:01:51 +0000 (07:01 +0900)
Implementing missing folder view callbacks...
JIRA issue: CORE-19616
- In CDefView::InvokeContextMenuCommand,
  call SFVM_GETCOMMANDDIR callback and
  store the directory into
  CMINVOKECOMMANDINFOEX structure.

dll/win32/shell32/CDefView.cpp

index a88b9de..93afb74 100644 (file)
@@ -1582,6 +1582,17 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr<IContextMenu>& pCM, LPCSTR lp
         cmi.ptInvoke = *pt;
     }
 
+    WCHAR szDirW[MAX_PATH] = L"";
+    CHAR szDirA[MAX_PATH];
+    if (SUCCEEDED(_DoFolderViewCB(SFVM_GETCOMMANDDIR, _countof(szDirW), (LPARAM)szDirW)) &&
+        *szDirW != UNICODE_NULL)
+    {
+        SHUnicodeToAnsi(szDirW, szDirA, _countof(szDirA));
+        cmi.fMask |= CMIC_MASK_UNICODE;
+        cmi.lpDirectory = szDirA;
+        cmi.lpDirectoryW = szDirW;
+    }
+
     HRESULT hr = pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)&cmi);
     // Most of our callers will do this, but if they would forget (File menu!)
     IUnknown_SetSite(pCM, NULL);