[BROWSEUI]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 30 Jul 2016 12:47:39 +0000 (12:47 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sat, 30 Jul 2016 12:47:39 +0000 (12:47 +0000)
- 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
reactos/dll/win32/browseui/addressband.h
reactos/dll/win32/browseui/addresseditbox.cpp

index 8b09dce..497c41a 100644 (file)
@@ -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<IBrowserService>                browserService;
     CComPtr<IShellService>                  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<IDispatch *>(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<IBrowserService> isb;
-    CComPtr<IShellFolder> 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<LPARAM>(&item)))
-        {
-            pidlPrevious = reinterpret_cast<LPITEMIDLIST>(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<LPARAM>(absolutePIDL);
-
-        if (itemExists)
-        {
-            result = SendMessage(m_hWnd, CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&item));
-            oldIndex = 0;
-
-            if (result)
-            {
-                ILFree(pidlPrevious);
-            }
-        }
-        else
-        {
-            oldIndex = SendMessage(m_hWnd, CBEM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&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)
index 057b491..33b6d9a 100644 (file)
@@ -32,8 +32,7 @@ class CAddressBand :
     public IServiceProvider,
     public IWinEventHandler,
     public IAddressBand,
-    public IInputObjectSite,
-    public IDispatch
+    public IInputObjectSite
 {
 private:
     CComPtr<IDockingWindowSite>             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()
 };
index d6b1adc..c0fa218 100644 (file)
@@ -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<IBrowserService> isb;
+    CComPtr<IShellFolder> 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<LPARAM>(&item)))
+        {
+            pidlPrevious = reinterpret_cast<LPITEMIDLIST>(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<LPARAM>(absolutePIDL);
+
+        if (itemExists)
+        {
+            result = fCombobox.SendMessage(CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&item));
+            oldIndex = 0;
+
+            if (result)
+            {
+                ILFree(pidlPrevious);
+            }
+        }
+        else
+        {
+            oldIndex = fCombobox.SendMessage(CBEM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&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;
 }