Index: dll/win32/browseui/addressband.cpp
===================================================================
--- dll/win32/browseui/addressband.cpp	(revision 71026)
+++ dll/win32/browseui/addressband.cpp	(working copy)
@@ -429,85 +429,16 @@
 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;
+        case DISPID_NAVIGATECOMPLETE2:
+        case DISPID_DOCUMENTCOMPLETE:
+            break;
     }
     return S_OK;
 }
Index: dll/win32/browseui/addresseditbox.h
===================================================================
--- dll/win32/browseui/addresseditbox.h	(revision 71026)
+++ dll/win32/browseui/addresseditbox.h	(working copy)
@@ -38,10 +38,16 @@
     DWORD                                   fAdviseCookie;
     CComPtr<IUnknown>                       fSite;
     LPITEMIDLIST                            pidlLastParsed;
+    LPITEMIDLIST                            fCurrentDirectoryPIDL;
+    HWND                                    hComboBoxEx;
 public:
     CAddressEditBox();
     ~CAddressEditBox();
 private:
+    void PopulateComboBox(LPITEMIDLIST pidl);
+    void AddComboBoxItem(LPITEMIDLIST pidl, int index, int indent);
+    void FillOneLevel(int index, int levelIndent, int indent);
+    LPITEMIDLIST GetItemData(int index);
 public:
     // *** IShellService methods ***
     virtual HRESULT STDMETHODCALLTYPE SetOwner(IUnknown *);
Index: dll/win32/browseui/addresseditbox.cpp
===================================================================
--- dll/win32/browseui/addresseditbox.cpp	(revision 71026)
+++ dll/win32/browseui/addresseditbox.cpp	(working copy)
@@ -48,6 +48,8 @@
 
 CAddressEditBox::~CAddressEditBox()
 {
+    if (fCurrentDirectoryPIDL)
+        ILFree(fCurrentDirectoryPIDL);
 }
 
 HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *)
@@ -73,6 +75,7 @@
     fCombobox.SubclassWindow(comboboxEx);
     fEditWindow.SubclassWindow(editControl);
     fSite = param18;
+    hComboBoxEx = comboboxEx;
 
     SHAutoComplete(fEditWindow.m_hWnd, SHACF_FILESYSTEM | SHACF_URLALL | SHACF_USETAB);
 
@@ -150,7 +153,7 @@
     HRESULT hr;
 
     /* 
-     * Parse the path is it wasn't parsed
+     * Parse the path if it wasn't parsed
      */
     if (!pidlLastParsed)
         ParseNow(0);
@@ -158,26 +161,9 @@
     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
+     * Check if the current pidl is the same as the parsed one
      */
-    PIDLIST_ABSOLUTE pidl;
-    hr = pbs->GetPidl(&pidl);
-    if (FAILED(hr))
-        return hr;
 
     CComPtr<IShellFolder> psf;
     hr = SHGetDesktopFolder(&psf);
@@ -184,9 +170,8 @@
     if (FAILED(hr))
         return hr;
 
-    hr = psf->CompareIDs(0, pidl, pidlLastParsed);
+    hr = psf->CompareIDs(0, fCurrentDirectoryPIDL, pidlLastParsed);
 
-    SHFree(pidl);
     if (hr == 0)
         return S_OK;
 
@@ -193,12 +178,18 @@
     /* 
      * Attempt to browse to the parsed pidl 
      */
+
+    CComPtr<IShellBrowser> pisb;
+    hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pisb));
+    if (FAILED(hr))
+        return hr;
+
     hr = pisb->BrowseObject(pidlLastParsed, 0);
     if (SUCCEEDED(hr))
         return hr;
 
     /* 
-     * Browsing to the pidl failed so it's not a folder. So invoke its defaule command.
+     * Browsing to the pidl failed so it's not a folder. So invoke its default command.
      */
     HWND topLevelWindow;
     hr = IUnknown_GetWindow(pisb, &topLevelWindow);
@@ -232,21 +223,38 @@
 
     switch (uMsg)
     {
-    case WM_NOTIFY:
-        hdr = (LPNMHDR) lParam;
-        if (hdr->code == CBEN_ENDEDIT)
+        case WM_COMMAND:
         {
-            NMCBEENDEDITW *endEdit = (NMCBEENDEDITW*) lParam;
-            if (endEdit->iWhy == CBENF_RETURN)
+            if (HIWORD(wParam) == CBN_SELCHANGE)
             {
+                UINT selectedIndex = SendMessageW((HWND)lParam, CB_GETCURSEL, 0, 0);
+                pidlLastParsed = (LPITEMIDLIST)SendMessageW((HWND)lParam, CB_GETITEMDATA, selectedIndex, 0);
                 Execute(0);
             }
-            else if (endEdit->iWhy == CBENF_ESCAPE)
+            break;
+        }
+        case WM_NOTIFY:
+
+            hdr = (LPNMHDR) lParam;
+            if (hdr->code == CBEN_ENDEDIT)
             {
-                /* Reset the contents of the combo box */
+                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;
+            if (hdr->code == CBEN_DELETEITEM)
+            {
+                NMCOMBOBOXEX *item = (NMCOMBOBOXEX*) lParam;
+                if (item->ceItem.lParam)
+                    ILFree((LPITEMIDLIST)item->ceItem.lParam);
+            }
+            break;
     }
     return S_OK;
 }
@@ -291,6 +299,13 @@
 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;
+    PIDLIST_ABSOLUTE absolutePIDL;
+    COMBOBOXEXITEMW item;
+    STRRET ret;
+
     if (pDispParams == NULL)
         return E_INVALIDARG;
 
@@ -298,7 +313,30 @@
     {
     case DISPID_NAVIGATECOMPLETE2:
     case DISPID_DOCUMENTCOMPLETE:
+        hr = IUnknown_QueryService(fSite, SID_STopLevelBrowser, IID_PPV_ARG(IBrowserService, &isb));
+        if (FAILED_UNEXPECTEDLY(hr))
+            return hr;
+        isb->GetPidl(&absolutePIDL);
+        fCurrentDirectoryPIDL = ILClone(absolutePIDL);
+
+        PopulateComboBox(absolutePIDL);
+        CComPtr<IShellFolder> psfDesktop;
+        SHGetDesktopFolder(&psfDesktop);
+        psfDesktop->GetDisplayNameOf(absolutePIDL, SHGDN_FORADDRESSBAR, &ret);
+        int index = SendMessageW(hComboBoxEx, CB_FINDSTRINGEXACT, 0, (LPARAM)ret.pOleStr);
+        if (index != -1)
+            SendMessageW(hComboBoxEx, CB_SETCURSEL, index, 0);
+
+        memset(&item, 0, sizeof(COMBOBOXEXITEMW));
+        psfDesktop->GetDisplayNameOf(absolutePIDL, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, &ret);
+        item.mask = CBEIF_TEXT | CBEIF_SELECTEDIMAGE | CBEIF_IMAGE;
+        item.iImage = SHMapPIDLToSystemImageListIndex(psfDesktop, absolutePIDL, &item.iSelectedImage);
+        item.pszText = ret.pOleStr;
+        item.iItem = -1;
+        SendMessageW(hComboBoxEx, CBEM_SETITEM, 0, (LPARAM)&item);
         pidlLastParsed = NULL;
+        ILFree(absolutePIDL);
+        break;
     }
     return S_OK;
 }
@@ -335,3 +373,117 @@
 {
     return ShellObjectCreator<CAddressEditBox>(riid, ppv);
 }
+
+void CAddressEditBox::PopulateComboBox(LPITEMIDLIST pidlCurrent)
+{
+    LPITEMIDLIST pidl;
+    int indent = 0;
+    int index;
+
+    index = SendMessageW(hComboBoxEx, CB_GETCOUNT, 0, 0);
+    for (int i = 0; i < index; i++)
+        SendMessageW(hComboBoxEx, CBEM_DELETEITEM, i, 0);
+    SendMessageW(hComboBoxEx, CB_RESETCONTENT, 0, 0);
+
+    pidl = ILClone(pidlCurrent);
+    do
+    {
+        if(!pidl->mkid.cb)
+            break;
+        pidl = ILGetNext(pidl);
+        indent++;
+    } while (pidl);
+    index = indent;
+    ILFree(pidl);
+    pidl = ILClone(pidlCurrent);
+    do
+    {
+        AddComboBoxItem(pidl, 0, index);
+        ILRemoveLastID(pidl);
+        index--;
+    } while (index >= 0);
+    ILFree(pidl);
+    FillOneLevel(0, 1, indent);
+    SHGetSpecialFolderLocation(0, CSIDL_DRIVES, &pidl);
+    for(LPITEMIDLIST i = GetItemData(0); i; i = GetItemData(index))
+    {
+        if (ILIsEqual(i, pidl))
+        {
+            FillOneLevel(index, 2, indent);
+            break;
+        }
+        index++;
+    }
+    ILFree(pidl);
+}
+
+void CAddressEditBox::AddComboBoxItem(LPITEMIDLIST pidl, int index, int indent)
+{
+    COMBOBOXEXITEMW item;
+    STRRET ret;
+    LPCITEMIDLIST pidlChild;
+    CComPtr<IShellFolder> sf;
+
+    memset(&item, 0, sizeof(COMBOBOXEXITEMW));
+
+    SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
+    sf->GetDisplayNameOf(pidlChild, SHGDN_FORADDRESSBAR, &ret);
+
+    item.mask = CBEIF_LPARAM | CBEIF_INDENT | CBEIF_SELECTEDIMAGE | CBEIF_IMAGE | CBEIF_TEXT;
+    item.iImage = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &item.iSelectedImage);
+    item.pszText = ret.pOleStr;
+    item.lParam = (LPARAM)(ILClone(pidl));
+    item.iIndent = indent;
+    item.iItem = index;
+    SendMessageW(hComboBoxEx, CBEM_INSERTITEMW, 0, (LPARAM)&item);
+}
+
+void CAddressEditBox::FillOneLevel(int index, int levelIndent, int indent)
+{
+    ULONG numObj;
+    int count;
+    LPITEMIDLIST pidl, pidl2, pidl3, pidl4;
+
+    count = index + 1;
+    pidl = GetItemData(index);
+    pidl2 = GetItemData(count);
+    if(pidl)
+    {
+        CComPtr<IShellFolder> psfDesktop;
+        CComPtr<IShellFolder> psfItem;
+
+        if (!pidl->mkid.cb)
+            SHGetDesktopFolder(&psfItem);
+        else
+        {
+            SHGetDesktopFolder(&psfDesktop);
+            psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &psfItem));
+        }
+        CComPtr<IEnumIDList> pEnumIDList;
+        psfItem->EnumObjects(0, SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN, &pEnumIDList);
+        do
+        {
+            if(pEnumIDList->Next(1, &pidl3, &numObj) || !numObj)
+                break;
+            pidl4 = ILAppendID(ILClone(pidl), (LPCSHITEMID)pidl3, 1);
+            if (pidl2 && ILIsEqual(pidl4, pidl2))
+                count += (indent - levelIndent);
+            else
+                AddComboBoxItem(pidl4, count, levelIndent);
+            count++;
+            ILFree(pidl3);
+            ILFree(pidl4);
+        } while (true);
+    }
+}
+
+LPITEMIDLIST CAddressEditBox::GetItemData(int index)
+{
+    COMBOBOXEXITEMW item;
+
+    memset(&item, 0, sizeof(COMBOBOXEXITEMW));
+    item.mask = CBEIF_LPARAM;
+    item.iItem = index;
+    SendMessageW(hComboBoxEx, CBEM_GETITEMW, 0, (LPARAM)&item);
+    return (LPITEMIDLIST)item.lParam;
+}
