[BROWSEUI] Fix CExplorerBand Right-Dragging menu (#6579)

Display correct menu on right-dragging
an item in Folder explorer bar to Desktop.
JIRA issue: CORE-19474
In CExplorerBand::OnTreeItemDragging
method:
- Use GetAttributesOf to get the
  attributes of a folder item.
- Use correct dwEffect value for
  DoDragDrop call.
This commit is contained in:
Katayama Hirofumi MZ 2024-03-06 08:11:32 +09:00 committed by GitHub
parent 1cc721e6d5
commit 361bf39872
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -374,27 +374,36 @@ void CExplorerBand::OnSelectionChanged(LPNMTREEVIEW pnmtv)
void CExplorerBand::OnTreeItemDragging(LPNMTREEVIEW pnmtv, BOOL isRightClick)
{
CComPtr<IShellFolder> pSrcFolder;
CComPtr<IDataObject> pObj;
LPCITEMIDLIST pLast;
HRESULT hr;
DWORD dwEffect;
DWORD dwEffect2;
dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
if (!pnmtv->itemNew.lParam)
return;
NodeInfo* pNodeInfo = GetNodeInfo(pnmtv->itemNew.hItem);
HRESULT hr;
CComPtr<IShellFolder> pSrcFolder;
LPCITEMIDLIST pLast;
hr = SHBindToParent(pNodeInfo->absolutePidl, IID_PPV_ARG(IShellFolder, &pSrcFolder), &pLast);
if (!SUCCEEDED(hr))
return;
hr = pSrcFolder->GetUIObjectOf(m_hWnd, 1, &pLast, IID_IDataObject, 0, reinterpret_cast<void**>(&pObj));
SFGAOF attrs = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK;
pSrcFolder->GetAttributesOf(1, &pLast, &attrs);
DWORD dwEffect = 0;
if (attrs & SFGAO_CANCOPY)
dwEffect |= DROPEFFECT_COPY;
if (attrs & SFGAO_CANMOVE)
dwEffect |= DROPEFFECT_MOVE;
if (attrs & SFGAO_CANLINK)
dwEffect |= DROPEFFECT_LINK;
CComPtr<IDataObject> pObj;
hr = pSrcFolder->GetUIObjectOf(m_hWnd, 1, &pLast, IID_IDataObject, 0, (LPVOID*)&pObj);
if (!SUCCEEDED(hr))
return;
DoDragDrop(pObj, this, dwEffect, &dwEffect2);
return;
}
DoDragDrop(pObj, this, dwEffect, &dwEffect);
}
// *** ATL event handlers ***
LRESULT CExplorerBand::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)