[SHELL32] Fix the toolbar buttons in the file open dialog

CDefView: Make GetItemObject return an IContectMenu after setting itself as the site.
CDefViewBckgrndMenu: Make the inner context menu use the same site. Implement handling CMDSTR_VIEWLISTA and CMDSTR_VIEWDETAILSA.
CDefaultContextMenu: CMDSTR_VIEWLISTA and CMDSTR_VIEWDETAILSA shouldn't be handled in this class.
Fixes CORE-14327 and the two buttons that change the view mode
This commit is contained in:
Giannis Adamopoulos 2018-02-15 00:23:18 +02:00
parent e4aa45f63a
commit b97886ea9f
3 changed files with 25 additions and 15 deletions

View file

@ -1110,8 +1110,6 @@ HRESULT CDefView::FillFileMenu()
if (FAILED_UNEXPECTEDLY(hr))
return hr;
IUnknown_SetSite(m_pCM, (IShellView *)this);
HMENU hmenu = CreatePopupMenu();
hr = m_pCM->QueryContextMenu(hmenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
@ -1274,8 +1272,6 @@ HRESULT CDefView::OpenSelectedItems()
if (FAILED_UNEXPECTEDLY(hResult))
goto cleanup;
IUnknown_SetSite(m_pCM, (IShellView *)this);
hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_DEFAULTONLY);
if (FAILED_UNEXPECTEDLY(hResult))
goto cleanup;
@ -1327,8 +1323,6 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
if (FAILED_UNEXPECTEDLY(hResult))
goto cleanup;
IUnknown_SetSite(m_pCM, (IShellView *)this);
/* Use 1 as the first id as we want 0 the mean that the user canceled the menu */
hResult = m_pCM->QueryContextMenu(m_hContextMenu, 0, CONTEXT_MENU_BASE_ID, FCIDM_SHVIEWLAST, CMF_NORMAL);
if (FAILED_UNEXPECTEDLY(hResult))
@ -1374,8 +1368,6 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection)
if (FAILED_UNEXPECTEDLY( hResult))
goto cleanup;
IUnknown_SetSite(m_pCM, (IShellView *)this);
hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
if (FAILED_UNEXPECTEDLY( hResult))
goto cleanup;
@ -2287,6 +2279,7 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
if (FAILED_UNEXPECTEDLY(hr))
return hr;
IUnknown_SetSite(*((IUnknown**)ppvOut), (IShellView *)this);
}
else if (IsEqualIID(riid, IID_IDispatch))
{
@ -2305,6 +2298,10 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
hr = m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, riid, 0, ppvOut);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (IsEqualIID(riid, IID_IContextMenu))
IUnknown_SetSite(*((IUnknown**)ppvOut), (IShellView *)this);
break;
}