From 7853148eb006e2178babd46de1b1a0e240d75882 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 30 Jul 2016 12:47:39 +0000 Subject: [PATCH] [BROWSEUI] - Move handling of DISPID_NAVIGATECOMPLETE2 event from CAddressBand to CAddressEditBox as the todo comments say it should be. - Remove the todo entries that are complete. - Remove IDispatch from CAddressBand as it is not really needed. Now CAddressBand takes care only of positioning and handling the button while CAddressEditBox does all the parsing and interaction with the browser. svn path=/trunk/; revision=72055 --- reactos/dll/win32/browseui/addressband.cpp | 115 ------------------ reactos/dll/win32/browseui/addressband.h | 11 +- reactos/dll/win32/browseui/addresseditbox.cpp | 77 ++++++++++-- 3 files changed, 71 insertions(+), 132 deletions(-) diff --git a/reactos/dll/win32/browseui/addressband.cpp b/reactos/dll/win32/browseui/addressband.cpp index 8b09dce2804..497c41af1f6 100644 --- a/reactos/dll/win32/browseui/addressband.cpp +++ b/reactos/dll/win32/browseui/addressband.cpp @@ -29,11 +29,8 @@ Implements the navigation band of the cabinet window /* TODO: -****Add command handler for show/hide Go button to OnWinEvent ****Add tooltip notify handler **Properly implement GetBandInfo - **Add correct text to Go button - **Implement TranslateAcceleratorIO Implement Exec Implement QueryService Implement Load @@ -46,7 +43,6 @@ CAddressBand::CAddressBand() fGoButton = NULL; fComboBox = NULL; fGoButtonShown = false; - fAdviseCookie = 0; } CAddressBand::~CAddressBand() @@ -103,7 +99,6 @@ HRESULT STDMETHODCALLTYPE CAddressBand::GetBandInfo(DWORD dwBandID, DWORD dwView HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown *pUnkSite) { - CComPtr browserService; CComPtr shellService; HWND parentWindow; HWND combobox; @@ -112,7 +107,6 @@ HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown *pUnkSite) if (pUnkSite == NULL) { - hResult = AtlUnadvise(fSite, DIID_DWebBrowserEvents, fAdviseCookie); fSite.Release(); return S_OK; } @@ -171,13 +165,6 @@ HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown *pUnkSite) if (fGoButtonShown) CreateGoButton(); - // take advice to watch events - hResult = IUnknown_QueryService(pUnkSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService)); - if (SUCCEEDED(hResult)) - { - hResult = AtlAdvise(browserService, static_cast(this), DIID_DWebBrowserEvents, &fAdviseCookie); - } - return hResult; } @@ -398,108 +385,6 @@ HRESULT STDMETHODCALLTYPE CAddressBand::GetSizeMax(ULARGE_INTEGER *pcbSize) return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE CAddressBand::GetTypeInfoCount(UINT *pctinfo) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CAddressBand::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CAddressBand::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, - LCID lcid, DISPID *rgDispId) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE CAddressBand::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, - DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) -{ - CComPtr isb; - CComPtr sf; - HRESULT hr; - INT indexClosed, indexOpen, itemExists, oldIndex; - DWORD result; - COMBOBOXEXITEMW item; - PIDLIST_ABSOLUTE absolutePIDL; - LPCITEMIDLIST pidlChild; - LPITEMIDLIST pidlPrevious; - STRRET ret; - WCHAR buf[4096]; - - if (pDispParams == NULL) - return E_INVALIDARG; - - switch (dispIdMember) - { - case DISPID_NAVIGATECOMPLETE2: - case DISPID_DOCUMENTCOMPLETE: - - oldIndex = SendMessage(m_hWnd, CB_GETCURSEL, 0, 0); - - itemExists = FALSE; - pidlPrevious = NULL; - - ZeroMemory(&item, sizeof(item)); - item.mask = CBEIF_LPARAM; - item.iItem = 0; - if (SendMessage(m_hWnd, CBEM_GETITEM, 0, reinterpret_cast(&item))) - { - pidlPrevious = reinterpret_cast(item.lParam); - if (pidlPrevious) - itemExists = TRUE; - } - - hr = IUnknown_QueryService(fSite, SID_STopLevelBrowser, IID_PPV_ARG(IBrowserService, &isb)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - isb->GetPidl(&absolutePIDL); - - SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild); - - sf->GetDisplayNameOf(pidlChild, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, &ret); - - StrRetToBufW(&ret, pidlChild, buf, 4095); - - indexClosed = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen); - - item.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM; - item.iItem = 0; - item.iImage = indexClosed; - item.iSelectedImage = indexOpen; - item.pszText = buf; - item.lParam = reinterpret_cast(absolutePIDL); - - if (itemExists) - { - result = SendMessage(m_hWnd, CBEM_SETITEM, 0, reinterpret_cast(&item)); - oldIndex = 0; - - if (result) - { - ILFree(pidlPrevious); - } - } - else - { - oldIndex = SendMessage(m_hWnd, CBEM_INSERTITEM, 0, reinterpret_cast(&item)); - - if (oldIndex < 0) - DbgPrint("ERROR %d\n", GetLastError()); - } - - SendMessage(m_hWnd, CB_SETCURSEL, -1, 0); - SendMessage(m_hWnd, CB_SETCURSEL, oldIndex, 0); - - //fAddressEditBox->SetCurrentDir(index); - - break; - } - return S_OK; -} - LRESULT CAddressBand::OnNotifyClick(WPARAM wParam, NMHDR *notifyHeader, BOOL &bHandled) { if (notifyHeader->hwndFrom == fGoButton) diff --git a/reactos/dll/win32/browseui/addressband.h b/reactos/dll/win32/browseui/addressband.h index 057b4913a8a..33b6d9a2bdc 100644 --- a/reactos/dll/win32/browseui/addressband.h +++ b/reactos/dll/win32/browseui/addressband.h @@ -32,8 +32,7 @@ class CAddressBand : public IServiceProvider, public IWinEventHandler, public IAddressBand, - public IInputObjectSite, - public IDispatch + public IInputObjectSite { private: CComPtr fSite; @@ -42,7 +41,6 @@ private: HWND fGoButton; HWND fComboBox; bool fGoButtonShown; - DWORD fAdviseCookie; public: CAddressBand(); virtual ~CAddressBand(); @@ -98,12 +96,6 @@ public: virtual HRESULT STDMETHODCALLTYPE Save(IStream *pStm, BOOL fClearDirty); virtual HRESULT STDMETHODCALLTYPE GetSizeMax(ULARGE_INTEGER *pcbSize); - // *** IDispatch methods *** - virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); - virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo); - virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); - virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); - // message handlers LRESULT OnNotifyClick(WPARAM wParam, NMHDR *notifyHeader, BOOL &bHandled); LRESULT OnTipText(UINT idControl, NMHDR *notifyHeader, BOOL &bHandled); @@ -137,6 +129,5 @@ public: COM_INTERFACE_ENTRY_IID(IID_IInputObjectSite, IInputObjectSite) COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream) - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch) END_COM_MAP() }; diff --git a/reactos/dll/win32/browseui/addresseditbox.cpp b/reactos/dll/win32/browseui/addresseditbox.cpp index d6b1adc58dc..c0fa218ae91 100644 --- a/reactos/dll/win32/browseui/addresseditbox.cpp +++ b/reactos/dll/win32/browseui/addresseditbox.cpp @@ -26,17 +26,10 @@ This class handles the combo box of the address band. /* TODO: - Add auto completion support - Subclass windows in Init method - Connect to browser connection point - Handle navigation complete messages to set edit box text Handle listbox dropdown message and fill contents Add drag and drop of icon in edit box - Handle enter in edit box to browse to typed path Handle change notifies to update appropriately - Add handling of enter in edit box Fix so selection in combo listbox navigates - Fix so editing text and typing enter navigates */ CAddressEditBox::CAddressEditBox() : @@ -291,6 +284,18 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::GetIDsOfNames( HRESULT STDMETHODCALLTYPE CAddressEditBox::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { + CComPtr isb; + CComPtr sf; + HRESULT hr; + INT indexClosed, indexOpen, itemExists, oldIndex; + DWORD result; + COMBOBOXEXITEMW item; + PIDLIST_ABSOLUTE absolutePIDL; + LPCITEMIDLIST pidlChild; + LPITEMIDLIST pidlPrevious; + STRRET ret; + WCHAR buf[4096]; + if (pDispParams == NULL) return E_INVALIDARG; @@ -299,6 +304,64 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Invoke(DISPID dispIdMember, REFIID ri case DISPID_NAVIGATECOMPLETE2: case DISPID_DOCUMENTCOMPLETE: pidlLastParsed = NULL; + + oldIndex = fCombobox.SendMessage(CB_GETCURSEL, 0, 0); + + itemExists = FALSE; + pidlPrevious = NULL; + + ZeroMemory(&item, sizeof(item)); + item.mask = CBEIF_LPARAM; + item.iItem = 0; + if (fCombobox.SendMessage(CBEM_GETITEM, 0, reinterpret_cast(&item))) + { + pidlPrevious = reinterpret_cast(item.lParam); + if (pidlPrevious) + itemExists = TRUE; + } + + hr = IUnknown_QueryService(fSite, SID_STopLevelBrowser, IID_PPV_ARG(IBrowserService, &isb)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + isb->GetPidl(&absolutePIDL); + + SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild); + + sf->GetDisplayNameOf(pidlChild, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, &ret); + + StrRetToBufW(&ret, pidlChild, buf, 4095); + + indexClosed = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen); + + item.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM; + item.iItem = 0; + item.iImage = indexClosed; + item.iSelectedImage = indexOpen; + item.pszText = buf; + item.lParam = reinterpret_cast(absolutePIDL); + + if (itemExists) + { + result = fCombobox.SendMessage(CBEM_SETITEM, 0, reinterpret_cast(&item)); + oldIndex = 0; + + if (result) + { + ILFree(pidlPrevious); + } + } + else + { + oldIndex = fCombobox.SendMessage(CBEM_INSERTITEM, 0, reinterpret_cast(&item)); + + if (oldIndex < 0) + DbgPrint("ERROR %d\n", GetLastError()); + } + + fCombobox.SendMessage(CB_SETCURSEL, -1, 0); + fCombobox.SendMessage(CB_SETCURSEL, oldIndex, 0); + + //fAddressEditBox->SetCurrentDir(index); } return S_OK; } -- 2.17.1