diff options
Diffstat (limited to '7zip/FileManager/PanelMenu.cpp')
-rwxr-xr-x | 7zip/FileManager/PanelMenu.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/7zip/FileManager/PanelMenu.cpp b/7zip/FileManager/PanelMenu.cpp index d4336fdd..091f0317 100755 --- a/7zip/FileManager/PanelMenu.cpp +++ b/7zip/FileManager/PanelMenu.cpp @@ -22,14 +22,15 @@ static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; void CPanel::InvokeSystemCommand(const char *command) { - if (!IsFSFolder()) + if (!IsFSFolder() && !IsFSDrivesFolder()) return; CRecordVector<UINT32> operatedIndices; GetOperatedItemIndices(operatedIndices); if (operatedIndices.IsEmpty()) return; CMyComPtr<IContextMenu> contextMenu; - CreateShellContextMenu(operatedIndices, contextMenu); + if (CreateShellContextMenu(operatedIndices, contextMenu) != S_OK) + return; CMINVOKECOMMANDINFO ci; ZeroMemory(&ci, sizeof(ci)); @@ -58,19 +59,19 @@ void CPanel::EditPaste() InvokeSystemCommand("paste"); } -void CPanel::CreateShellContextMenu( +HRESULT CPanel::CreateShellContextMenu( const CRecordVector<UINT32> &operatedIndices, CMyComPtr<IContextMenu> &systemContextMenu) { systemContextMenu.Release(); - UString folderPath = _currentFolderPrefix; + UString folderPath = GetFsPath(); CMyComPtr<IShellFolder> desktopFolder; - ::SHGetDesktopFolder(&desktopFolder); + RINOK(::SHGetDesktopFolder(&desktopFolder)); if (!desktopFolder) { // ShowMessage("Failed to get Desktop folder."); - return; + return E_FAIL; } // Separate the file from the folder. @@ -80,24 +81,19 @@ void CPanel::CreateShellContextMenu( // is located in. LPITEMIDLIST parentPidl; DWORD eaten; - DWORD result = desktopFolder->ParseDisplayName( + RINOK(desktopFolder->ParseDisplayName( GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath, - &eaten, &parentPidl, 0); - if (result != NOERROR) - { - // ShowMessage("Invalid file name."); - return; - } + &eaten, &parentPidl, 0)); // Get an IShellFolder for the folder // the file is located in. CMyComPtr<IShellFolder> parentFolder; - result = desktopFolder->BindToObject(parentPidl, - 0, IID_IShellFolder, (void**)&parentFolder); + RINOK(desktopFolder->BindToObject(parentPidl, + 0, IID_IShellFolder, (void**)&parentFolder)); if (!parentFolder) { // ShowMessage("Invalid file name."); - return; + return E_FAIL; } // Get a pidl for the file itself. @@ -107,10 +103,10 @@ void CPanel::CreateShellContextMenu( { LPITEMIDLIST pidl; UString fileName = GetItemName(operatedIndices[i]); - HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0, - (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0); - if (result != NOERROR) - return; + if (IsFSDrivesFolder()) + fileName += L'\\'; + RINOK(parentFolder->ParseDisplayName(GetParent(), 0, + (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0)); pidls.Add(pidl); } @@ -130,14 +126,15 @@ void CPanel::CreateShellContextMenu( // Get the IContextMenu for the file. CMyComPtr<IContextMenu> cm; - result = parentFolder->GetUIObjectOf(GetParent(), pidls.Size(), - (LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm); + RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(), + (LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm)); if (!cm) { // ShowMessage("Unable to get context menu interface."); - return; + return E_FAIL; } systemContextMenu = cm; + return S_OK; } void CPanel::CreateSystemMenu(HMENU menuSpec, |