From c25856d1c0971c156e2e224aa87e7669e2841fb0 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Tue, 24 Jun 2025 15:45:43 +0200 Subject: [PATCH] [BROWSEUI] Fix CompareIDs lParam passed to inner folder (#8161) CORE-20250 --- dll/win32/browseui/shellfind/CFindFolder.cpp | 5 ++--- dll/win32/browseui/shellfind/CSearchBar.cpp | 5 +++-- dll/win32/shell32/CDefView.cpp | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dll/win32/browseui/shellfind/CFindFolder.cpp b/dll/win32/browseui/shellfind/CFindFolder.cpp index fb072923a19..02a9ee27b0b 100644 --- a/dll/win32/browseui/shellfind/CFindFolder.cpp +++ b/dll/win32/browseui/shellfind/CFindFolder.cpp @@ -845,7 +845,7 @@ STDMETHODIMP CFindFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELL if (iColumn == COL_RELEVANCE_INDEX) { // TODO: Fill once the relevance is calculated - return SHSetStrRet(&pDetails->str, ""); + return SHSetStrRetEmpty(&pDetails->str); } ATLASSERT(iColumn == COL_NAME_INDEX); @@ -903,8 +903,7 @@ STDMETHODIMP CFindFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PC wColumn -= _countof(g_ColumnDefs) - 1; break; } - // FIXME: DefView does not like the way we sort - return m_pisfInner->CompareIDs(HIWORD(lParam) | wColumn, _ILGetFSPidl(pidl1), _ILGetFSPidl(pidl2)); + return m_pisfInner->CompareIDs(MAKELONG(wColumn, HIWORD(lParam)), _ILGetFSPidl(pidl1), _ILGetFSPidl(pidl2)); } STDMETHODIMP CFindFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) diff --git a/dll/win32/browseui/shellfind/CSearchBar.cpp b/dll/win32/browseui/shellfind/CSearchBar.cpp index 8fb7ae3321b..732d650faec 100644 --- a/dll/win32/browseui/shellfind/CSearchBar.cpp +++ b/dll/win32/browseui/shellfind/CSearchBar.cpp @@ -885,7 +885,8 @@ void CSearchBar::TrySetFocus(UINT Source) { BOOL IsOnButton = GetDlgItem(IDC_SEARCH_BUTTON) == hWndFocus; BOOL IsOnSelfPane = hWndFocus == m_hWnd; - if (!hWndFocus || IsOnSelfPane || IsOnButton || !IsWindowChildOf(hWndFocus, m_hWnd)) - SendMessageW(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_SEARCH_FILENAME), TRUE); + BOOL IsInPaneChild = hWndFocus && IsWindowChildOf(hWndFocus, m_hWnd); + if ((cItems == 0 && !IsInPaneChild) || IsOnSelfPane || IsOnButton) + SendMessage(WM_NEXTDLGCTL, (WPARAM)GetDlgItem(IDC_SEARCH_FILENAME), TRUE); } } diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 2d34f1f53d3..4cae91a25ba 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -1365,13 +1365,14 @@ int CDefView::LV_FindItemByPidl(PCUITEMID_CHILD pidl) } else { - for (i = 0; i < cItems; i++) +#if DBG + for (i = 0; pidl && i < cItems; i++) { - //FIXME: ILIsEqual needs absolute pidls! currentpidl = _PidlByItem(i); - if (ILIsEqual(pidl, currentpidl)) - return i; + if (currentpidl && currentpidl->mkid.cb == pidl->mkid.cb && !memcmp(currentpidl, pidl, pidl->mkid.cb)) + DbgPrint("Matched item #%d, broken CompareIDs?\n", i); } +#endif break; } }