From 7544656b85cd694d6c1aaed6da5b36110b290a37 Mon Sep 17 00:00:00 2001 From: Brock Mammen Date: Thu, 18 Jul 2019 21:28:11 -0500 Subject: [PATCH] [SHELLFIND] Open search results folder with search button --- dll/win32/browseui/shellfind/CSearchBar.cpp | 22 +++++++++++++++++++++ dll/win32/browseui/shellfind/CSearchBar.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/dll/win32/browseui/shellfind/CSearchBar.cpp b/dll/win32/browseui/shellfind/CSearchBar.cpp index b07b5aced75..f2329b6e250 100644 --- a/dll/win32/browseui/shellfind/CSearchBar.cpp +++ b/dll/win32/browseui/shellfind/CSearchBar.cpp @@ -112,6 +112,28 @@ LRESULT CSearchBar::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bH return TRUE; } +LRESULT CSearchBar::OnSearchButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + CComPtr pShellBrowser; + HRESULT hr = IUnknown_QueryService(pSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pShellBrowser)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + WCHAR szShellGuid[MAX_PATH]; + const WCHAR shellGuidPrefix[] = L"shell:::"; + memcpy(szShellGuid, shellGuidPrefix, sizeof(shellGuidPrefix)); + hr = StringFromGUID2(CLSID_FindFolder, szShellGuid + _countof(shellGuidPrefix) - 1, _countof(szShellGuid) - _countof(shellGuidPrefix)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + LPITEMIDLIST findFolderPidl; + hr = SHParseDisplayName(szShellGuid, NULL, &findFolderPidl, 0, NULL); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + return pShellBrowser->BrowseObject(findFolderPidl, 0); +} + // *** IOleWindow methods *** HRESULT STDMETHODCALLTYPE CSearchBar::GetWindow(HWND *lphwnd) diff --git a/dll/win32/browseui/shellfind/CSearchBar.h b/dll/win32/browseui/shellfind/CSearchBar.h index 5ab67b4134d..81c9455b980 100644 --- a/dll/win32/browseui/shellfind/CSearchBar.h +++ b/dll/win32/browseui/shellfind/CSearchBar.h @@ -47,6 +47,7 @@ private: // *** ATL event handlers *** LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled); + LRESULT OnSearchButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); public: CSearchBar(); @@ -134,5 +135,6 @@ public: BEGIN_MSG_MAP(CSearchBar) MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) + COMMAND_CODE_HANDLER(BN_CLICKED, OnSearchButtonClicked) END_MSG_MAP() };