mirror of
https://github.com/reactos/reactos.git
synced 2025-03-01 03:45:16 +00:00
parent
a236c39ee5
commit
556cc8a7b2
2 changed files with 51 additions and 0 deletions
|
@ -20,6 +20,33 @@ WINE_DEFAULT_DEBUG_CHANNEL(shellfind);
|
|||
#define UNIMPLEMENTED DbgPrint("%s is UNIMPLEMENTED!\n", __FUNCTION__)
|
||||
#endif
|
||||
|
||||
static BOOL IsWindowChildOf(const HWND hNeedle, const HWND hRoot)
|
||||
{
|
||||
if (hNeedle != hRoot)
|
||||
{
|
||||
for (HWND hParent = hNeedle; hParent;)
|
||||
{
|
||||
hParent = GetParent(hParent);
|
||||
if (hParent == hRoot)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static UINT GetShellViewItemCount(IShellView *pSV)
|
||||
{
|
||||
int signedCount;
|
||||
CComQIIDPtr<I_ID(IFolderView)> pFV(pSV);
|
||||
if (pFV && SUCCEEDED(pFV->ItemCount(SVGIO_ALLVIEW, &signedCount)))
|
||||
return signedCount;
|
||||
UINT unsignedCount;
|
||||
CComQIIDPtr<I_ID(IShellFolderView)> pSFV(pSV);
|
||||
if (pSFV && SUCCEEDED(pSFV->GetObjectCount(&unsignedCount)))
|
||||
return unsignedCount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CSearchBar::CSearchBar() :
|
||||
m_pSite(NULL),
|
||||
m_bVisible(FALSE)
|
||||
|
@ -336,6 +363,8 @@ HRESULT STDMETHODCALLTYPE CSearchBar::ShowDW(BOOL fShow)
|
|||
{
|
||||
m_bVisible = fShow;
|
||||
ShowWindow(fShow);
|
||||
if (fShow)
|
||||
TrySetFocus(DISPID_WINDOWSTATECHANGED);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -562,6 +591,7 @@ HRESULT STDMETHODCALLTYPE CSearchBar::Invoke(DISPID dispIdMember, REFIID riid, L
|
|||
case DISPID_DOCUMENTCOMPLETE:
|
||||
{
|
||||
TrySubscribeToSearchEvents();
|
||||
TrySetFocus(DISPID_NAVIGATECOMPLETE2);
|
||||
|
||||
// Remove the search results folder from the address box
|
||||
CComPtr<IDispatch> pDispatch;
|
||||
|
@ -606,8 +636,28 @@ HRESULT STDMETHODCALLTYPE CSearchBar::Invoke(DISPID dispIdMember, REFIID riid, L
|
|||
case DISPID_SEARCHCOMPLETE:
|
||||
case DISPID_SEARCHABORT:
|
||||
SetSearchInProgress(FALSE);
|
||||
TrySetFocus(DISPID_SEARCHCOMPLETE);
|
||||
return S_OK;
|
||||
default:
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
||||
void CSearchBar::TrySetFocus(UINT Source)
|
||||
{
|
||||
CComPtr<IShellBrowser> pBrowser;
|
||||
CComPtr<IShellView> pResultsSV;
|
||||
if (SUCCEEDED(GetSearchResultsFolder(&pBrowser, NULL, NULL)))
|
||||
pBrowser->QueryActiveShellView(&pResultsSV);
|
||||
UINT cItems = pResultsSV ? GetShellViewItemCount(pResultsSV) : 0;
|
||||
|
||||
// Attempt to set the focus if we are not in the results folder or if there are no results
|
||||
HWND hWndFocus = ::GetFocus();
|
||||
if (!hWndFocus || !pResultsSV || cItems == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ private:
|
|||
BOOL GetAddressEditBoxPath(WCHAR *szPath);
|
||||
void SetSearchInProgress(BOOL bInProgress);
|
||||
HRESULT TrySubscribeToSearchEvents();
|
||||
void TrySetFocus(UINT Source);
|
||||
|
||||
// *** ATL event handlers ***
|
||||
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
|
||||
|
|
Loading…
Reference in a new issue