mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 01:43:02 +00:00
[SHELL32][BROWSEUI] CopyMoveToMenu must initialize without a PIDL folder (#7047)
- IShellExtInit cannot rely on a folder PIDL being present - Use common QueryContextMenu function for both menu items - Allow copy to the same folder - Disable toolbar buttons when the selection is not valid - Minor DefView cache enhancement and bugfixes
This commit is contained in:
parent
df5affedce
commit
d24675b63d
6 changed files with 128 additions and 145 deletions
|
@ -723,6 +723,17 @@ void CDefView::UpdateStatusbar()
|
|||
m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETICON, 2, pIcon, &lResult);
|
||||
m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXT, 2, (LPARAM)szPartText, &lResult);
|
||||
}
|
||||
|
||||
SFGAOF att = 0;
|
||||
if (cSelectedItems > 0)
|
||||
{
|
||||
UINT maxquery = 42; // Checking the attributes can be slow, only check small selections (_DoCopyToMoveToFolder will verify the full array)
|
||||
att = SFGAO_CANCOPY | SFGAO_CANMOVE;
|
||||
if (cSelectedItems <= maxquery && (!GetSelections() || FAILED(m_pSFParent->GetAttributesOf(m_cidl, m_apidl, &att))))
|
||||
att = 0;
|
||||
}
|
||||
m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, FCIDM_SHVIEW_COPYTO, (att & SFGAO_CANCOPY) != 0, &lResult);
|
||||
m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON, FCIDM_SHVIEW_MOVETO, (att & SFGAO_CANMOVE) != 0, &lResult);
|
||||
}
|
||||
|
||||
LRESULT CDefView::OnUpdateStatusbar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||
|
@ -1947,15 +1958,18 @@ LRESULT CDefView::DoColumnContextMenu(LPARAM lParam)
|
|||
*/
|
||||
UINT CDefView::GetSelections()
|
||||
{
|
||||
SHFree(m_apidl);
|
||||
|
||||
m_cidl = m_ListView.GetSelectedCount();
|
||||
m_apidl = static_cast<PCUITEMID_CHILD*>(SHAlloc(m_cidl * sizeof(PCUITEMID_CHILD)));
|
||||
if (!m_apidl)
|
||||
UINT count = m_ListView.GetSelectedCount();
|
||||
if (count > m_cidl || !count || !m_apidl) // !count to free possibly large cache, !m_apidl to make sure m_apidl is a valid pointer
|
||||
{
|
||||
m_cidl = 0;
|
||||
return 0;
|
||||
SHFree(m_apidl);
|
||||
m_apidl = static_cast<PCUITEMID_CHILD*>(SHAlloc(count * sizeof(PCUITEMID_CHILD)));
|
||||
if (!m_apidl)
|
||||
{
|
||||
m_cidl = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
m_cidl = count;
|
||||
|
||||
TRACE("-- Items selected =%u\n", m_cidl);
|
||||
|
||||
|
@ -2025,8 +2039,7 @@ HRESULT CDefView::OpenSelectedItems()
|
|||
UINT uCommand;
|
||||
HRESULT hResult;
|
||||
|
||||
m_cidl = m_ListView.GetSelectedCount();
|
||||
if (m_cidl == 0)
|
||||
if (m_ListView.GetSelectedCount() == 0)
|
||||
return S_OK;
|
||||
|
||||
hResult = OnDefaultCommand();
|
||||
|
@ -2100,9 +2113,9 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
|
|||
}
|
||||
}
|
||||
|
||||
m_cidl = m_ListView.GetSelectedCount();
|
||||
UINT count = m_ListView.GetSelectedCount();
|
||||
// In case we still have this left over, clean it up
|
||||
hResult = GetItemObject(m_cidl ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
|
||||
hResult = GetItemObject(count ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
|
||||
MenuCleanup _(m_pCM, m_hContextMenu);
|
||||
if (FAILED_UNEXPECTEDLY(hResult))
|
||||
return 0;
|
||||
|
@ -3382,7 +3395,7 @@ HRESULT STDMETHODCALLTYPE CDefView::SelectAndPositionItems(UINT cidl, PCUITEMID_
|
|||
m_ListView.SetItemState(-1, 0, LVIS_SELECTED);
|
||||
|
||||
int lvIndex;
|
||||
for (UINT i = 0 ; i < m_cidl; i++)
|
||||
for (UINT i = 0 ; i < cidl; i++)
|
||||
{
|
||||
lvIndex = LV_FindItemByPidl(apidl[i]);
|
||||
if (lvIndex != -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue