[BROWSEUI]
authorDavid Quintana <gigaherz@gmail.com>
Fri, 7 Mar 2014 22:28:55 +0000 (22:28 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Fri, 7 Mar 2014 22:28:55 +0000 (22:28 +0000)
* Load and use rshell for the menubar.
* Properly forward WM_NOTIFY and WM_COMMAND messages to the toolbars.

[RSHELL]
* Improve behaviour of horizontal menubands.
* Clicking on submenu items does not work yet.

CORE-7586

svn path=/branches/shell-experiments/; revision=62448

base/shell/rshell/CMakeLists.txt
base/shell/rshell/CMenuBand.cpp
base/shell/rshell/CMenuBand.h
base/shell/rshell/CMenuDeskBar.cpp
base/shell/rshell/CMenuToolbars.cpp
base/shell/rshell/CMenuToolbars.h
dll/win32/browseui/CMakeLists.txt
dll/win32/browseui/internettoolbar.cpp
dll/win32/browseui/internettoolbar.h
dll/win32/browseui/precomp.h
media/fonts/Marlett.ttf

index ae88c16..46d23a7 100644 (file)
@@ -49,3 +49,9 @@ add_custom_command(TARGET rshell POST_BUILD
      "$<TARGET_FILE:rshell>"
      "$<TARGET_FILE_DIR:explorer_new>/$<TARGET_FILE_NAME:rshell>" 
   COMMENT "Copying to output directory")
+
+add_custom_command(TARGET rshell POST_BUILD 
+  COMMAND "${CMAKE_COMMAND}" -E copy 
+     "$<TARGET_FILE:rshell>"
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:rshell>" 
+  COMMENT "Copying to output directory")
index 272c130..23222fe 100644 (file)
@@ -52,7 +52,10 @@ CMenuBand::CMenuBand() :
     m_site(NULL),
     m_psmc(NULL),
     m_subMenuChild(NULL),
+    m_hmenu(NULL),
+    m_menuOwner(NULL),
     m_useBigIcons(FALSE),
+    m_topLevelWindow(NULL),
     m_hotBar(NULL),
     m_hotItem(-1)
 {
@@ -123,7 +126,7 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetMenu(
         m_staticToolbar = new CMenuStaticToolbar(this);
     }
     m_hmenu = hmenu;
-    m_menuOwner;
+    m_menuOwner = hwnd;
 
     HRESULT hr = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
     if (FAILED_UNEXPECTEDLY(hr))
@@ -203,7 +206,7 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetSite(IUnknown *pUnkSite)
     }
 
     hr = IUnknown_QueryService(m_site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup, &m_subMenuParent));
-    if (FAILED_UNEXPECTEDLY(hr))
+    if (FAILED(hr) && hr != E_NOINTERFACE)
         return hr;
 
     CComPtr<IOleWindow> pTopLevelWindow;
@@ -326,10 +329,13 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::ShowDW(BOOL fShow)
             return hr;
     }
 
-    if (fShow)
-        hr = m_focusManager->PushMenu(this);
-    else
-        hr = m_focusManager->PopMenu(this);
+    if (m_dwFlags & SMINIT_VERTICAL)
+    {
+        if (fShow)
+            hr = m_focusManager->PushMenu(this);
+        else
+            hr = m_focusManager->PopMenu(this);
+    }
 
     return S_OK;
 }
@@ -401,6 +407,8 @@ HRESULT STDMETHODCALLTYPE CMenuBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdI
         {
             return S_FALSE;
         }
+
+        return S_FALSE;
     }
 
     UNIMPLEMENTED;
@@ -610,9 +618,24 @@ HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id, LPI
     return hr;
 }
 
-HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y)
+HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, RECT& rcExclude)
 {
-    ::TrackPopupMenu(popup, 0, x, y, 0, m_menuOwner, NULL);
+    HWND sendTo = m_menuOwner;
+
+    // FIXME: use?
+    //TPMPARAMS params = { sizeof(TPMPARAMS), rcExclude };
+
+    if (sendTo)
+    {
+        ::TrackPopupMenuEx(popup, 0, x, y, sendTo, NULL); // &params);
+    }
+    else
+    {
+        GetWindow(&sendTo);
+        ::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, sendTo, NULL); // &params);
+        // TODO: use the result somehow
+    }
+
     return S_OK;
 }
 
index 1e6fec1..b487d6e 100644 (file)
@@ -171,7 +171,7 @@ public:
 
     HRESULT _CallCBWithItemId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam);
     HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam);
-    HRESULT _TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y);
+    HRESULT _TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, RECT& rcExclude);
     HRESULT _GetTopLevelWindow(HWND*topLevel);
     HRESULT _OnHotItemChanged(CMenuToolbarBase * tb, INT id);
     HRESULT _MenuItemHotTrack(DWORD changeType);
index 5feed65..6e310bc 100644 (file)
@@ -417,7 +417,7 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::SetSubMenu(IMenuPopup *pmp, BOOL fSet)
     {
         if (m_SubMenuChild)
         {
-            if (SHIsSameObject(pmp, m_SubMenuChild))
+            if (pmp == m_SubMenuChild)
             {
                 m_SubMenuChild = NULL;
             }
index 4d79750..526f722 100644 (file)
@@ -67,6 +67,10 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
         hdr = reinterpret_cast<LPNMHDR>(lParam);
         switch (hdr->code)
         {
+        case TTN_GETDISPINFOA:
+        case TTN_GETDISPINFOW:
+            return S_OK;
+
         case PGN_CALCSIZE:
             csize = reinterpret_cast<LPNMPGCALCSIZE>(hdr);
 
@@ -99,7 +103,8 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
             switch (cdraw->nmcd.dwDrawStage)
             {
             case CDDS_PREPAINT:
-                *theResult = CDRF_NOTIFYITEMDRAW;
+                if (m_toolbarFlags & SMINIT_VERTICAL)
+                    *theResult = CDRF_NOTIFYITEMDRAW;
                 return S_OK;
 
             case CDDS_ITEMPREPAINT:
@@ -160,6 +165,10 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
                 return S_OK;
             }
             return S_OK;
+        case RBN_CHILDSIZE:
+            return S_OK;
+        default:
+            DbgPrint("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
         }
         return S_OK;
     }
@@ -214,6 +223,13 @@ HRESULT CMenuToolbarBase::ShowWindow(BOOL fShow)
 
 HRESULT CMenuToolbarBase::UpdateImageLists()
 {
+    if ((m_toolbarFlags & (SMINIT_TOPLEVEL| SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical.
+    {
+        /* Hide the placeholders for the button images */
+        SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
+        return S_OK;
+    }
+
     int shiml;
     if (m_menuBand->UseBigIcons())
     {
@@ -266,6 +282,8 @@ HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
 #endif
     }
 
+    m_toolbarFlags = dwFlags;
+
     RECT rc;
 
     if (!::GetClientRect(hwndParent, &rc) || (rc.left == rc.right) || (rc.top == rc.bottom))
@@ -311,13 +329,6 @@ HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
     /* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */
     SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
 
-    //if (dwFlags & SMINIT_TOPLEVEL)
-    //{
-    //    /* Hide the placeholders for the button images */
-    //    SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
-    //}
-    //else
-
     SetWindowLongPtr(hwndToolbar, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
     m_SubclassOld = (WNDPROC) SetWindowLongPtr(hwndToolbar, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(CMenuToolbarBase::s_SubclassProc));
 
@@ -349,8 +360,11 @@ HRESULT CMenuToolbarBase::SetPosSize(int x, int y, int cx, int cy)
         SetWindowPos(m_hwndToolbar, NULL, x, y, cx, m_idealSize.cy, 0);
     }
     SetWindowPos(m_hwnd, NULL, x, y, cx, cy, 0);
-    DWORD btnSize = SendMessage(m_hwndToolbar, TB_GETBUTTONSIZE, 0, 0);
-    SendMessage(m_hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, HIWORD(btnSize)));
+    if (m_toolbarFlags & SMINIT_VERTICAL)
+    {
+        DWORD btnSize = SendMessage(m_hwndToolbar, TB_GETBUTTONSIZE, 0, 0);
+        SendMessage(m_hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(cx, HIWORD(btnSize)));
+    }
     return S_OK;
 }
 
@@ -372,8 +386,16 @@ LRESULT CALLBACK CMenuToolbarBase::s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM w
 
 LRESULT CMenuToolbarBase::SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
+    LRESULT lr;
+
     switch (uMsg)
     {
+    case WM_COMMAND:
+        OnWinEvent(hWnd, uMsg, wParam, lParam, &lr);
+        break;
+    case WM_NOTIFY:
+        OnWinEvent(hWnd, uMsg, wParam, lParam, &lr);
+        break;
     case WM_TIMER:
         if (wParam == TIMERID_HOTTRACK)
         {
@@ -402,9 +424,12 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot)
     }
     else if (m_hotItem != hot->idNew)
     {
-        DWORD elapsed = 0;
-        SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
-        SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL);
+        if (m_toolbarFlags & SMINIT_VERTICAL)
+        {
+            DWORD elapsed = 0;
+            SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
+            SetTimer(m_hwndToolbar, TIMERID_HOTTRACK, elapsed, NULL);
+        }
 
         m_hotItem = hot->idNew;
         m_menuBand->_OnHotItemChanged(this, m_hotItem);
@@ -415,8 +440,18 @@ HRESULT CMenuToolbarBase::OnHotItemChange(const NMTBHOTITEM * hot)
 
 HRESULT CMenuToolbarBase::OnHotItemChanged(CMenuToolbarBase * toolbar, INT item)
 {
+    BOOL wasChecked = FALSE;
+    if (m_hotBar == this && !(m_toolbarFlags & SMINIT_VERTICAL))
+    {
+        wasChecked = SendMessage(m_hwndToolbar, TB_ISBUTTONCHECKED, m_hotItem, 0);
+        SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, FALSE);
+    }
     m_hotBar = toolbar;
     m_hotItem = item;
+    if (wasChecked && m_hotBar == this && !(m_toolbarFlags & SMINIT_VERTICAL))
+    {
+        SendMessage(m_hwndToolbar, TB_CHECKBUTTON, m_hotItem, TRUE);
+    }
     InvalidateDraw();
     return S_OK;
 }
@@ -436,18 +471,25 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
 
     HRESULT hr = 0;
     RECT rc = { 0 };
+    RECT rcx = { 0 };
 
     if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
         return E_FAIL;
 
+    GetWindowRect(m_hwnd, &rcx);
+
     POINT a = { rc.left, rc.top };
     POINT b = { rc.right, rc.bottom };
+    POINT c = { rcx.left, rcx.top };
+    POINT d = { rcx.right, rcx.bottom };
 
     ClientToScreen(m_hwndToolbar, &a);
     ClientToScreen(m_hwndToolbar, &b);
+    ClientToScreen(m_hwnd, &c);
+    ClientToScreen(m_hwnd, &d);
 
     POINTL pt = { b.x - 3, a.y - 3 };
-    RECTL rcl = { a.x, a.y, b.x, b.y }; // maybe-TODO: fetch client area of deskbar?
+    RECTL rcl = { c.x, c.y, d.x, d.y };
 
 #if USE_SYSTEM_MENUSITE
     hr = CoCreateInstance(CLSID_MenuBandSite,
@@ -499,20 +541,40 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, IShellMenu* child
     return S_OK;
 }
 
-HRESULT CMenuToolbarBase::PopupSubMenu(UINT index, HMENU menu)
+HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, HMENU menu)
 {
     RECT rc = { 0 };
+    RECT rcx = { 0 };
 
     if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
         return E_FAIL;
 
+    GetWindowRect(m_hwnd, &rcx);
+
+    POINT a = { rc.left, rc.top };
     POINT b = { rc.right, rc.bottom };
+    POINT c = { rcx.left, rcx.top };
+    POINT d = { rcx.right, rcx.bottom };
 
+    ClientToScreen(m_hwndToolbar, &a);
     ClientToScreen(m_hwndToolbar, &b);
+    ClientToScreen(m_hwnd, &c);
+    ClientToScreen(m_hwnd, &d);
+
+    POINT pt = { a.x, b.y };
+    RECT rcl = { c.x, c.y, d.x, d.y };
+
+    if (m_toolbarFlags & SMINIT_VERTICAL)
+    {
+        pt.x = b.x;
+        pt.y = a.y;
+    }
 
     HMENU popup = GetSubMenu(menu, index);
 
-    m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, b.x, b.y);
+    m_menuBand->_TrackSubMenuUsingTrackPopupMenu(popup, pt.x, pt.y, rcl);
+
+    SendMessage(m_hwndToolbar, TB_CHECKBUTTON, uItem, FALSE);
 
     return S_OK;
 }
@@ -653,22 +715,23 @@ HRESULT CMenuToolbarBase::AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSu
 
     tbb.fsState = TBSTATE_ENABLED;
 #ifndef TBSTYLE_EX_VERTICAL
-    if (!last)
+    if (!last && (m_toolbarFlags & SMINIT_VERTICAL))
         tbb.fsState |= TBSTATE_WRAP;
 #endif
     tbb.fsStyle = 0;
 
-    if (hasSubMenu)
+    if (hasSubMenu && (m_toolbarFlags & SMINIT_VERTICAL))
         tbb.fsStyle |= BTNS_DROPDOWN;
 
+    if (!(m_toolbarFlags & SMINIT_VERTICAL))
+        tbb.fsStyle |= BTNS_AUTOSIZE | BTNS_CHECKGROUP;
+
     tbb.iString = (INT_PTR) caption;
     tbb.idCommand = commandId;
 
     tbb.iBitmap = iconId;
     tbb.dwData = buttonData;
 
-    DbgPrint("Trying to add a new button with id %d and caption '%S'...\n", commandId, caption);
-
     if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
         return HRESULT_FROM_WIN32(GetLastError());
 
@@ -681,14 +744,12 @@ HRESULT CMenuToolbarBase::AddSeparator(BOOL last)
 
     tbb.fsState = TBSTATE_ENABLED;
 #ifndef TBSTYLE_EX_VERTICAL
-    if (!last)
+    if (!last && (m_toolbarFlags & SMINIT_VERTICAL))
         tbb.fsState |= TBSTATE_WRAP;
 #endif
     tbb.fsStyle = BTNS_SEP;
     tbb.iBitmap = 0;
 
-    DbgPrint("Trying to add a new separator...\n");
-
     if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
         return HRESULT_FROM_WIN32(GetLastError());
 
@@ -705,8 +766,6 @@ HRESULT CMenuToolbarBase::AddPlaceholder()
     tbb.iString = (INT_PTR) MenuString;
     tbb.iBitmap = -1;
 
-    DbgPrint("Trying to add a new placeholder...\n");
-
     if (!SendMessageW(m_hwndToolbar, TB_ADDBUTTONS, 1, reinterpret_cast<LPARAM>(&tbb)))
         return HRESULT_FROM_WIN32(GetLastError());
 
@@ -810,8 +869,6 @@ HRESULT CMenuStaticToolbar::FillToolbar()
 
         count++;
 
-        DbgPrint("Found item with fType=%x, cmdId=%d\n", info.fType, info.wID);
-
         if (info.fType & MFT_SEPARATOR)
         {
             AddSeparator(last);
@@ -839,8 +896,6 @@ HRESULT CMenuStaticToolbar::FillToolbar()
         }
     }
 
-    DbgPrint("Created toolbar with %d buttons.\n", count);
-
     return S_OK;
 }
 
@@ -876,7 +931,7 @@ HRESULT CMenuStaticToolbar::InternalPopupItem(INT uItem, INT index, DWORD_PTR dw
 
     if (nfo->dwFlags&SMIF_TRACKPOPUP)
     {
-        return PopupSubMenu(index, m_hmenu);
+        return PopupSubMenu(uItem, index, m_hmenu);
     }
     else
     {
@@ -951,13 +1006,9 @@ HRESULT CMenuSFToolbar::FillToolbar()
     // If no items were added, show the "empty" placeholder
     if (i == 0)
     {
-        DbgPrint("The toolbar is empty, adding placeholder.\n");
-
         return AddPlaceholder();
     }
 
-    DbgPrint("Created toolbar with %d buttons.\n", i);
-
     return hr;
 }
 
index 5fcd2fc..984e4bc 100644 (file)
@@ -42,6 +42,8 @@ protected:
     CMenuToolbarBase * m_popupBar;
     INT                m_popupItem;
 
+    DWORD m_toolbarFlags;
+
 private:
     static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
@@ -61,7 +63,7 @@ public:
     HRESULT OnPopupItemChanged(CMenuToolbarBase * toolbar, INT item);
 
     HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
-    HRESULT PopupSubMenu(UINT index, HMENU menu);
+    HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
     HRESULT DoContextMenu(IContextMenu* contextMenu);
 
     HRESULT ChangeHotItem(DWORD changeType);
index 8305bd8..b242d01 100644 (file)
@@ -59,3 +59,9 @@ add_importlibs(browseui
 
 add_pch(browseui precomp.h SOURCE)
 add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all)
+
+add_custom_command(TARGET browseui POST_BUILD 
+  COMMAND "${CMAKE_COMMAND}" -E copy 
+     "$<TARGET_FILE:browseui>"
+     "$<TARGET_FILE_DIR:filebrowser>/$<TARGET_FILE_NAME:browseui>" 
+  COMMENT "Copying to output directory")
index adfd6ef..3541c56 100644 (file)
@@ -67,6 +67,8 @@ extern HRESULT CreateBrandBand(REFIID riid, void **ppv);
 extern HRESULT CreateBandProxy(REFIID riid, void **ppv);
 extern HRESULT CreateAddressBand(REFIID riid, void **ppv);
 
+typedef HRESULT(*PMENUBAND_CONSTRUCTOR)(REFIID riid, void **ppv);
+
 class CInternetToolbar;
 
 class CDockSite :
@@ -372,8 +374,23 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
         favoritesHMenu = GetSubMenu(parentHMenu, 3);
         if (favoritesHMenu == NULL)
             return E_FAIL;
+#if 1
+        HMODULE hrs = LoadLibrary(L"rshell.dll");
+
+        PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
+        if (func)
+        {
+            hResult = func(IID_PPV_ARG(IShellMenu, &newMenu));
+        }
+        else
+        {
+            hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
+                IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+        }
+#else
         hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
             IID_IShellMenu, reinterpret_cast<void **>(&newMenu));
+#endif
         if (FAILED(hResult))
             return hResult;
         hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED);
@@ -536,8 +553,35 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
     HWND                                    ownerWindow;
     HRESULT                                 hResult;
 
+#if 1
+    HMODULE hrs = LoadLibraryW(L"rshell.dll");
+
+    if (!hrs)
+    {
+        DbgPrint("Failed: %d\n", GetLastError());
+        return E_FAIL;
+    }
+
+    PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
+    if (func)
+    {
+        hResult = func(IID_PPV_ARG(IShellMenu, menuBar));
+    }
+    else
+    {
+        DbgPrint("Failed: %d\n", GetLastError());
+        hResult = E_FAIL;
+    }
+    
+    if (FAILED(hResult))
+    {
+        hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
+            IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+    }
+#else
     hResult = CoCreateInstance(CLSID_MenuBand, NULL, CLSCTX_INPROC_SERVER,
         IID_IShellMenu, reinterpret_cast<void **>(menuBar));
+#endif
     if (FAILED(hResult))
         return hResult;
     hResult = fMenuCallback.QueryInterface(IID_IShellMenuCallback, reinterpret_cast<void **>(&callback));
@@ -1137,12 +1181,16 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::OnWinEvent(
     CComPtr<IWinEventHandler>               menuWinEventHandler;
     HRESULT                                 hResult;
 
-    if (fMenuBar.p != NULL)
+    if (fMenuBar)
     {
         hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
-        return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
+        if (menuWinEventHandler->IsWindowOwner(hWnd))
+        {
+            return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
+        }
     }
-    return E_FAIL;
+
+    return S_FALSE;
 }
 
 HRESULT STDMETHODCALLTYPE CInternetToolbar::IsWindowOwner(HWND hWnd)
@@ -1410,20 +1458,6 @@ LRESULT CInternetToolbar::OnQueryDelete(UINT idControl, NMHDR *pNMHDR, BOOL &bHa
     return 1;
 }
 
-LRESULT CInternetToolbar::OnNavigateCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
-{
-    CComPtr<IWinEventHandler>               winEventHandler;
-    LRESULT                                 theResult;
-    HRESULT                                 hResult;
-
-    hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&winEventHandler));
-    hResult = winEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult);
-    if (SUCCEEDED(hResult))
-        return theResult;
-    bHandled = FALSE;
-    return 0;
-}
-
 LRESULT CInternetToolbar::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 {
     HMENU                                   contextMenuBar;
@@ -1553,27 +1587,78 @@ LRESULT CInternetToolbar::OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandle
     return 0;
 }
 
+LRESULT CInternetToolbar::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+    LRESULT theResult;
+    HRESULT hResult;
+    HWND    target = (HWND) lParam;
+
+    if (fMenuBar)
+    {
+        CComPtr<IWinEventHandler> menuWinEventHandler;
+        hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+        if (SUCCEEDED(hResult))
+        {
+            if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
+            {
+                hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
+                return FAILED(hResult) ? 0 : theResult;
+            }
+        }
+    }
+
+    if (fNavigationBar)
+    {
+        CComPtr<IWinEventHandler> menuWinEventHandler;
+        hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+        if (SUCCEEDED(hResult))
+        {
+            if (menuWinEventHandler->IsWindowOwner(target) == S_OK)
+            {
+                hResult = menuWinEventHandler->OnWinEvent(target, uMsg, wParam, lParam, &theResult);
+                return FAILED(hResult) ? 0 : theResult;
+            }
+        }
+    }
+
+    return 0;
+}
 LRESULT CInternetToolbar::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 {
-    NMHDR                                   *notifyHeader;
-    CComPtr<IWinEventHandler>               menuWinEventHandler;
-    LRESULT                                 theResult;
-    HRESULT                                 hResult;
+    NMHDR   *notifyHeader;
+    LRESULT theResult;
+    HRESULT hResult;
 
-    notifyHeader = (NMHDR *)lParam;
-    if (fMenuBar.p != NULL && notifyHeader->hwndFrom == fMenuBandWindow)
+    notifyHeader = (NMHDR *) lParam;
+
+    if (fMenuBar)
     {
+        CComPtr<IWinEventHandler> menuWinEventHandler;
         hResult = fMenuBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
-        hResult = menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, &theResult);
-        return theResult;
+        if (SUCCEEDED(hResult))
+        {
+            if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
+            {
+                hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
+                return FAILED(hResult) ? 0 : theResult;
+            }
+        }
     }
-    if (fNavigationBar.p != NULL && notifyHeader->hwndFrom == fNavigationWindow)
+
+    if (fNavigationBar)
     {
-        hResult = fNavigationBar->QueryInterface(
-            IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
-        hResult = menuWinEventHandler->OnWinEvent(m_hWnd, uMsg, wParam, lParam, &theResult);
-        return theResult;
+        CComPtr<IWinEventHandler> menuWinEventHandler;
+        hResult = fNavigationBar->QueryInterface(IID_IWinEventHandler, reinterpret_cast<void **>(&menuWinEventHandler));
+        if (SUCCEEDED(hResult))
+        {
+            if (menuWinEventHandler->IsWindowOwner(notifyHeader->hwndFrom) == S_OK)
+            {
+                hResult = menuWinEventHandler->OnWinEvent(notifyHeader->hwndFrom, uMsg, wParam, lParam, &theResult);
+                return FAILED(hResult) ? 0 : theResult;
+            }
+        }
     }
+
     return 0;
 }
 
index 71520e3..0b6ae67 100644 (file)
@@ -196,6 +196,7 @@ public:
     LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
     LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
     LRESULT OnTipText(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
+    LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
     LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
 
     BEGIN_MSG_MAP(CInternetToolbar)
@@ -208,7 +209,7 @@ public:
         NOTIFY_HANDLER(0, TBN_DROPDOWN, OnMenuDropDown)
         NOTIFY_HANDLER(0, TBN_QUERYINSERT, OnQueryInsert)
         NOTIFY_HANDLER(0, TBN_QUERYDELETE, OnQueryDelete)
-        MESSAGE_HANDLER(WM_COMMAND, OnNavigateCommand)
+        MESSAGE_HANDLER(WM_COMMAND, OnCommand)
         MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
         MESSAGE_HANDLER(WM_SIZE, OnSize)
         MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
index 45880e3..f365ac0 100644 (file)
 #include "commonbrowser.h"
 #include "globalfoldersettings.h"
 #include "regtreeoptions.h"
+#include <stdio.h>
+
+static __inline ULONG
+Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
+{
+    char szMsg[512];
+    char *szMsgStart;
+    const char *fname;
+    va_list vl;
+    ULONG uRet;
+
+    fname = strrchr(filename, '\\');
+    if (fname == NULL)
+    {
+        fname = strrchr(filename, '/');
+        if (fname != NULL)
+            fname++;
+    }
+    else
+        fname++;
+
+    if (fname == NULL)
+        fname = filename;
+
+    szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
+
+    va_start(vl, lpFormat);
+    uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
+    va_end(vl);
+
+    OutputDebugStringA(szMsg);
+
+    return uRet;
+}
+
+#define DbgPrint(fmt, ...) \
+    Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
 
 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
 
index 945aca8..ff7e3e8 100644 (file)
Binary files a/media/fonts/Marlett.ttf and b/media/fonts/Marlett.ttf differ