https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b97886ea9f17c62a849634053ef3dd0521a00848

commit b97886ea9f17c62a849634053ef3dd0521a00848
Author:     Giannis Adamopoulos <gadamopou...@reactos.org>
AuthorDate: Thu Feb 15 00:23:18 2018 +0200
Commit:     Giannis Adamopoulos <gadamopou...@reactos.org>
CommitDate: Thu Feb 15 00:23:18 2018 +0200

    [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
---
 dll/win32/shell32/CDefView.cpp            | 13 +++++--------
 dll/win32/shell32/CDefViewBckgrndMenu.cpp | 23 +++++++++++++++++++----
 dll/win32/shell32/CDefaultContextMenu.cpp |  4 +---
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp
index 9863205273..c3d37e5c0e 100644
--- a/dll/win32/shell32/CDefView.cpp
+++ b/dll/win32/shell32/CDefView.cpp
@@ -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;
     }
 
diff --git a/dll/win32/shell32/CDefViewBckgrndMenu.cpp 
b/dll/win32/shell32/CDefViewBckgrndMenu.cpp
index 3815019894..5636cdf548 100644
--- a/dll/win32/shell32/CDefViewBckgrndMenu.cpp
+++ b/dll/win32/shell32/CDefViewBckgrndMenu.cpp
@@ -126,6 +126,10 @@ WINAPI
 CDefViewBckgrndMenu::SetSite(IUnknown *pUnkSite)
 {
     m_site = pUnkSite;
+
+    if(m_folderCM)
+        IUnknown_SetSite(m_folderCM, pUnkSite);
+
     return S_OK;
 }
 
@@ -212,7 +216,16 @@ WINAPI
 CDefViewBckgrndMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
 {
     UINT idCmd = LOWORD(lpcmi->lpVerb);
-    if(HIWORD(lpcmi->lpVerb) != 0 || idCmd < m_LastFolderCMId)
+
+    if (HIWORD(lpcmi->lpVerb) && !strcmp(lpcmi->lpVerb, CMDSTR_VIEWLISTA))
+    {
+        idCmd = FCIDM_SHVIEW_LISTVIEW;
+    }
+    else if (HIWORD(lpcmi->lpVerb) && !strcmp(lpcmi->lpVerb, 
CMDSTR_VIEWDETAILSA))
+    {
+        idCmd = FCIDM_SHVIEW_REPORTVIEW;
+    }
+    else if(HIWORD(lpcmi->lpVerb) != 0 || idCmd < m_LastFolderCMId)
     {
         if (m_folderCM)
         {
@@ -221,9 +234,11 @@ CDefViewBckgrndMenu::InvokeCommand(LPCMINVOKECOMMANDINFO 
lpcmi)
         WARN("m_folderCM is NULL!\n");
         return E_NOTIMPL;
     }
-
-    /* The default part of the background menu doesn't have shifted ids so we 
need to convert the id offset to the real id */
-    idCmd += m_idCmdFirst;
+    else
+    {
+        /* The default part of the background menu doesn't have shifted ids so 
we need to convert the id offset to the real id */
+        idCmd += m_idCmdFirst;
+    }
 
     /* The commands that are handled by the def view are forwarded to it */
     switch (idCmd)
diff --git a/dll/win32/shell32/CDefaultContextMenu.cpp 
b/dll/win32/shell32/CDefaultContextMenu.cpp
index 13d084ffbb..dcb754bd96 100644
--- a/dll/win32/shell32/CDefaultContextMenu.cpp
+++ b/dll/win32/shell32/CDefaultContextMenu.cpp
@@ -47,9 +47,7 @@ struct _StaticInvokeCommandMap_
     { "Print", 0 },  // Unimplemented
     { "Preview", 0 }, // Unimplemented
     { "Open", FCIDM_SHVIEW_OPEN },
-    { CMDSTR_NEWFOLDERA, FCIDM_SHVIEW_NEWFOLDER },
-    { CMDSTR_VIEWLISTA, FCIDM_SHVIEW_LISTVIEW },
-    { CMDSTR_VIEWDETAILSA, FCIDM_SHVIEW_REPORTVIEW }
+    { CMDSTR_NEWFOLDERA, FCIDM_SHVIEW_NEWFOLDER }
 };
 
 

Reply via email to