Author: gadamopoulos Date: Sun Oct 26 23:46:35 2014 New Revision: 65036
URL: http://svn.reactos.org/svn/reactos?rev=65036&view=rev Log: [BROWSUI] - Fix CAddressBand::Invoke to correctly detect if an item exists in the list and select the correct item when it does. - Improve CAddressEditBox::Execute to check if the passed pidl is the one that is being displayed. - Also fix it to parse the path if needed. - Directly call CAddressEditBox::Execute when enter is pressed or the Go button is pressed - Should fix most issues with the address bar
Modified: branches/shell-experiments/dll/win32/browseui/addressband.cpp branches/shell-experiments/dll/win32/browseui/addresseditbox.cpp
Modified: branches/shell-experiments/dll/win32/browseui/addressband.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/brow... ============================================================================== --- branches/shell-experiments/dll/win32/browseui/addressband.cpp [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/browseui/addressband.cpp [iso-8859-1] Sun Oct 26 23:46:35 2014 @@ -489,12 +489,17 @@
oldIndex = SendMessage(m_hWnd, CB_GETCURSEL, 0, 0);
+ itemExists = FALSE; + pidlPrevious = NULL; + + ZeroMemory(&item, sizeof(item)); item.mask = CBEIF_LPARAM; item.iItem = 0; - itemExists = SendMessage(m_hWnd, CBEM_GETITEM, 0, reinterpret_cast<LPARAM>(&item)); - if (itemExists) + if (SendMessage(m_hWnd, CBEM_GETITEM, 0, reinterpret_cast<LPARAM>(&item))) { pidlPrevious = reinterpret_cast<LPITEMIDLIST>(item.lParam); + if (pidlPrevious) + itemExists = TRUE; }
hr = IUnknown_QueryService(fSite, SID_STopLevelBrowser, IID_PPV_ARG(IBrowserService, &isb)); @@ -520,6 +525,7 @@ if (itemExists) { result = SendMessage(m_hWnd, CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&item)); + oldIndex = 0;
if (result) {
Modified: branches/shell-experiments/dll/win32/browseui/addresseditbox.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/brow... ============================================================================== --- branches/shell-experiments/dll/win32/browseui/addresseditbox.cpp [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/browseui/addresseditbox.cpp [iso-8859-1] Sun Oct 26 23:46:35 2014 @@ -149,30 +149,72 @@ { HRESULT hr;
+ /* + * Parse the path is it wasn't parsed + */ + if (!pidlLastParsed) + ParseNow(0); + if (!pidlLastParsed) return E_FAIL;
+ /* + * Get the IShellBrowser and IBrowserService interfaces of the shell browser + */ CComPtr<IShellBrowser> pisb; hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pisb)); + if (FAILED(hr)) + return hr; + + CComPtr<IBrowserService> pbs; + pisb->QueryInterface(IID_PPV_ARG(IBrowserService, &pbs)); + if (FAILED(hr)) + return hr; + + /* + * Get the current pidl of the shellbrowser and check if it is the same with the parsed one + */ + PIDLIST_ABSOLUTE pidl; + hr = pbs->GetPidl(&pidl); + if (FAILED(hr)) + return hr; + + CComPtr<IShellFolder> psf; + hr = SHGetDesktopFolder(&psf); + if (FAILED(hr)) + return hr; + + hr = psf->CompareIDs(0, pidl, pidlLastParsed); + + SHFree(pidl); + if (hr == 0) + return S_OK; + + /* + * Attempt to browse to the parsed pidl + */ + hr = pisb->BrowseObject(pidlLastParsed, 0); if (SUCCEEDED(hr)) - { - hr = pisb->BrowseObject(pidlLastParsed, 0); - if (FAILED_UNEXPECTEDLY(hr)) - { - HWND topLevelWindow; - LPCITEMIDLIST pidlChild; - CComPtr<IShellFolder> sf; - CComPtr<IShellBrowser> pisb; - - hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pisb)); - - IUnknown_GetWindow(pisb, &topLevelWindow); - - hr = SHBindToParent(pidlLastParsed, IID_PPV_ARG(IShellFolder, &sf), &pidlChild); - - SHInvokeDefaultCommand(topLevelWindow, sf, pidlChild); - } - } + return hr; + + /* + * Browsing to the pidl failed so it's not a folder. So invoke its defaule command. + */ + HWND topLevelWindow; + hr = IUnknown_GetWindow(pisb, &topLevelWindow); + if (FAILED(hr)) + return hr; + + LPCITEMIDLIST pidlChild; + CComPtr<IShellFolder> sf; + hr = SHBindToParent(pidlLastParsed, IID_PPV_ARG(IShellFolder, &sf), &pidlChild); + if (FAILED(hr)) + return hr; + + hr = SHInvokeDefaultCommand(topLevelWindow, sf, pidlChild); + if (FAILED(hr)) + return hr; + return hr; }
@@ -194,7 +236,15 @@ hdr = (LPNMHDR) lParam; if (hdr->code == CBEN_ENDEDIT) { - ParseNow(0); + NMCBEENDEDITW *endEdit = (NMCBEENDEDITW*) lParam; + if (endEdit->iWhy == CBENF_RETURN) + { + Execute(0); + } + else if (endEdit->iWhy == CBENF_ESCAPE) + { + /* Reset the contents of the combo box */ + } } break; }