Skip to content

Commit

Permalink
[BROWSEUI][SHELL32] Treat OnWinEvent's result parameter as optional. …
Browse files Browse the repository at this point in the history
…CORE-14443

Windows's explorer can call it with NULL.
  • Loading branch information
ThFabba committed Mar 8, 2018
1 parent 84a9284 commit 0aed0fd
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 19 deletions.
3 changes: 2 additions & 1 deletion dll/win32/browseui/addressband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ HRESULT STDMETHODCALLTYPE CAddressBand::OnWinEvent(
HRESULT hResult;
RECT rect;

*theResult = 0;
if (theResult)
*theResult = 0;

switch (uMsg)
{
Expand Down
3 changes: 2 additions & 1 deletion dll/win32/browseui/addresseditbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::OnWinEvent(
{
LPNMHDR hdr;

*theResult = 0;
if (theResult)
*theResult = 0;

switch (uMsg)
{
Expand Down
5 changes: 4 additions & 1 deletion dll/win32/browseui/basebarsite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ HRESULT STDMETHODCALLTYPE CBaseBarSite::OnWinEvent(
NMHDR *notifyHeader;
// RECT newBounds;
HRESULT hResult;
LRESULT result;

hResult = S_OK;
if (uMsg == WM_NOTIFY)
Expand All @@ -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;
}
}
Expand Down
20 changes: 14 additions & 6 deletions dll/win32/browseui/explorerband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion dll/win32/browseui/shellbars/CBandSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 10 additions & 6 deletions dll/win32/browseui/shellbars/CISFBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion dll/win32/shell32/shellmenu/CMenuBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 8 additions & 2 deletions dll/win32/shell32/shellmenu/CMenuToolbars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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));
Expand Down

1 comment on commit 0aed0fd

@JoachimHenze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case anybody ever considers porting Thomas commit back further,
Thomas commit relies on the addendum 0.4.15-dev-3229-g22e58e6 https://git.reactos.org/?p=reactos.git;a=commit;h=22e58e68aa35a1ba49d280b12f99f7f03f5f8633 to prevent it from introducing the regression CORE-15251.

Please sign in to comment.