[BROWSEUI][SHELL32] Treat OnWinEvent's result parameter as optional. CORE-14443 425/head
authorThomas Faber <thomas.faber@reactos.org>
Thu, 8 Mar 2018 09:28:33 +0000 (10:28 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 8 Mar 2018 11:21:24 +0000 (12:21 +0100)
Windows's explorer can call it with NULL.

dll/win32/browseui/addressband.cpp
dll/win32/browseui/addresseditbox.cpp
dll/win32/browseui/basebarsite.cpp
dll/win32/browseui/explorerband.cpp
dll/win32/browseui/shellbars/CBandSite.cpp
dll/win32/browseui/shellbars/CISFBand.cpp
dll/win32/shell32/shellmenu/CMenuBand.cpp
dll/win32/shell32/shellmenu/CMenuToolbars.cpp

index 55164a9..c319dbd 100644 (file)
@@ -290,7 +290,8 @@ HRESULT STDMETHODCALLTYPE CAddressBand::OnWinEvent(
     HRESULT                                 hResult;
     RECT                                    rect;
 
-    *theResult = 0;
+    if (theResult)
+        *theResult = 0;
 
     switch (uMsg)
     {
index 091272d..f5748ec 100644 (file)
@@ -256,7 +256,8 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::OnWinEvent(
 {
     LPNMHDR hdr;
 
-    *theResult = 0;
+    if (theResult)
+        *theResult = 0;
 
     switch (uMsg)
     {
index 5a53387..8d2675d 100644 (file)
@@ -322,6 +322,7 @@ HRESULT STDMETHODCALLTYPE CBaseBarSite::OnWinEvent(
     NMHDR                                   *notifyHeader;
     // RECT                                    newBounds;
     HRESULT                                 hResult;
+    LRESULT                                 result;
     
     hResult = S_OK;
     if (uMsg == WM_NOTIFY)
@@ -342,7 +343,9 @@ HRESULT STDMETHODCALLTYPE CBaseBarSite::OnWinEvent(
 #endif
                     break;
                 case NM_CUSTOMDRAW:
-                    *theResult = OnCustomDraw((LPNMCUSTOMDRAW)lParam);
+                    result = OnCustomDraw((LPNMCUSTOMDRAW)lParam);
+                    if (theResult)
+                        *theResult = result;
                     return S_OK;
             }
         }
index 2b398bd..968b173 100644 (file)
@@ -1265,13 +1265,17 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
 HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 {
     BOOL bHandled;
+    LRESULT result;
+
     if (uMsg == WM_NOTIFY)
     {
         NMHDR *pNotifyHeader = (NMHDR*)lParam;
         switch (pNotifyHeader->code)
         {
             case TVN_ITEMEXPANDING:
-                *theResult = OnTreeItemExpanding((LPNMTREEVIEW)lParam);
+                result = OnTreeItemExpanding((LPNMTREEVIEW)lParam);
+                if (theResult)
+                    *theResult = result;
                 break;
             case TVN_SELCHANGED:
                 OnSelectionChanged((LPNMTREEVIEW)lParam);
@@ -1281,7 +1285,8 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
                 break;
             case NM_RCLICK:
                 OnContextMenu(WM_CONTEXTMENU, (WPARAM)m_hWnd, GetMessagePos(), bHandled);
-                *theResult = 1;
+                if (theResult)
+                    *theResult = 1;
                 break;
             case TVN_BEGINDRAG:
             case TVN_BEGINRDRAG:
@@ -1295,7 +1300,8 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
                 LPCITEMIDLIST pChild;
                 HRESULT hr;
 
-                *theResult = 1;
+                if (theResult)
+                    *theResult = 1;
                 NodeInfo *info = GetNodeInfo(dispInfo->item.hItem);
                 if (!info)
                     return E_FAIL;
@@ -1304,7 +1310,7 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
                     return E_FAIL;
 
                 hr = pParent->GetAttributesOf(1, &pChild, &dwAttr);
-                if (SUCCEEDED(hr) && (dwAttr & SFGAO_CANRENAME))
+                if (SUCCEEDED(hr) && (dwAttr & SFGAO_CANRENAME) && theResult)
                     *theResult = 0;
                 return S_OK;
             }
@@ -1314,7 +1320,8 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
                 NodeInfo *info = GetNodeInfo(dispInfo->item.hItem);
                 HRESULT hr;
 
-                *theResult = 0;
+                if (theResult)
+                    *theResult = 0;
                 if (dispInfo->item.pszText)
                 {
                     LPITEMIDLIST pidlNew;
@@ -1345,7 +1352,8 @@ HRESULT STDMETHODCALLTYPE CExplorerBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
 
                         ILFree(pidlNewAbs);
                         ILFree(pidlNew);
-                        *theResult = 1;
+                        if (theResult)
+                            *theResult = 1;
                     }
                     return S_OK;
                 }
index 13f78a2..fea22c3 100644 (file)
@@ -708,7 +708,8 @@ HRESULT STDMETHODCALLTYPE CBandSiteBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
 
     TRACE("(%p, %p, %u, %p, %p, %p)\n", this, hWnd, uMsg, wParam, lParam, plrResult);
 
-    *plrResult = 0;
+    if (plrResult)
+        *plrResult = 0;
     if (m_hwndRebar == NULL)
         return E_FAIL;
 
index 8d538c2..722d72b 100644 (file)
@@ -342,7 +342,8 @@ HRESULT CISFBand::CreateSimpleToolbar(HWND hWndParent)
                 if (chk)
                     SHInvokeDefaultCommand(m_hWnd, m_pISF, (LPITEMIDLIST)tb.dwData);
 
-                *theResult = TRUE;
+                if (theResult)
+                    *theResult = TRUE;
                 break;
             }            
             case WM_NOTIFY:
@@ -393,18 +394,21 @@ HRESULT CISFBand::CreateSimpleToolbar(HWND hWndParent)
                             }
                         }
                         DestroyMenu(fmenu);
-                        
-                        *theResult = TRUE;
+
+                        if (theResult)
+                            *theResult = TRUE;
                         break;
                     }
                     default:
-                        *theResult = FALSE;
+                        if (theResult)
+                            *theResult = FALSE;
                 }
 
                 break;
             }
-            default: 
-                *theResult = FALSE;
+            default:
+                if (theResult)
+                    *theResult = FALSE;
         }
 
         return S_OK;              
index e09bc00..49cb279 100644 (file)
@@ -723,7 +723,8 @@ HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIS
 
 HRESULT STDMETHODCALLTYPE CMenuBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 {
-    *theResult = 0;
+    if (theResult)
+        *theResult = 0;
 
     if (uMsg == WM_WININICHANGE && wParam == SPI_SETFLATMENU)
     {
index a33070a..fd98086 100644 (file)
@@ -49,8 +49,11 @@ LRESULT CMenuToolbarBase::OnWinEventWrap(UINT uMsg, WPARAM wParam, LPARAM lParam
 HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 {
     NMHDR * hdr;
+    HRESULT hr;
+    LRESULT result;
 
-    *theResult = 0;
+    if (theResult)
+        *theResult = 0;
     switch (uMsg)
     {
     case WM_COMMAND:
@@ -75,7 +78,10 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
             return S_OK;
 
         case NM_CUSTOMDRAW:
-            return OnCustomDraw(reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr), theResult);
+            hr = OnCustomDraw(reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr), &result);
+            if (theResult)
+                *theResult = result;
+            return hr;
 
         case TBN_GETINFOTIP:
             return OnGetInfoTip(reinterpret_cast<LPNMTBGETINFOTIP>(hdr));