[RSHELL]
authorDavid Quintana <gigaherz@gmail.com>
Mon, 10 Mar 2014 12:01:37 +0000 (12:01 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Mon, 10 Mar 2014 12:01:37 +0000 (12:01 +0000)
* Give TrackPopupMenuEx the top-level window. Need to figure out how Windows does this, it probably does not simply use the top-level window that way.
* Give TrackPopupMenuEx better flags and a better exclude rect.
CORE-7586

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

base/shell/rshell/CMenuBand.cpp
base/shell/rshell/CMenuToolbars.cpp
dll/win32/browseui/internettoolbar.cpp

index 23222fe..5a1ba6e 100644 (file)
@@ -622,18 +622,22 @@ HRESULT CMenuBand::_TrackSubMenuUsingTrackPopupMenu(HMENU popup, INT x, INT y, R
 {
     HWND sendTo = m_menuOwner;
 
-    // FIXME: use?
-    //TPMPARAMS params = { sizeof(TPMPARAMS), rcExclude };
+    TPMPARAMS params = { sizeof(TPMPARAMS), rcExclude };
+
+    UINT flags = TPM_VERPOSANIMATION | TPM_VERTICAL | TPM_LEFTALIGN;
 
     if (sendTo)
     {
-        ::TrackPopupMenuEx(popup, 0, x, y, sendTo, NULL); // &params);
+        ::TrackPopupMenuEx(popup, flags, x, y, sendTo, &params);
     }
     else
     {
+        // FIXME: Windows uses the top-level window when calling TrackPopupMenuEx,
+        // but this is probably not the means by which it obtains that HWND.
+        // Meanwhile, this works.
         GetWindow(&sendTo);
-        ::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, sendTo, NULL); // &params);
-        // TODO: use the result somehow
+        sendTo = GetAncestor(sendTo, GA_ROOT);
+        ::TrackPopupMenuEx(popup, flags, x, y, sendTo, &params);
     }
 
     return S_OK;
index 526f722..197055c 100644 (file)
@@ -549,17 +549,17 @@ HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, UINT index, HMENU menu)
     if (!SendMessage(m_hwndToolbar, TB_GETITEMRECT, index, reinterpret_cast<LPARAM>(&rc)))
         return E_FAIL;
 
-    GetWindowRect(m_hwnd, &rcx);
+    GetClientRect(m_hwndToolbar, &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 };
+    POINT c = { rc.left, rc.top };
+    POINT d = { rc.right, rc.bottom };
 
     ClientToScreen(m_hwndToolbar, &a);
     ClientToScreen(m_hwndToolbar, &b);
-    ClientToScreen(m_hwnd, &c);
-    ClientToScreen(m_hwnd, &d);
+    ClientToScreen(m_hwndToolbar, &c);
+    ClientToScreen(m_hwndToolbar, &d);
 
     POINT pt = { a.x, b.y };
     RECT rcl = { c.x, c.y, d.x, d.y };
index 3541c56..99ca619 100644 (file)
@@ -25,6 +25,8 @@ toolbar, and address band for an explorer window
 
 #include "precomp.h"
 
+#define USE_CUSTOM_MENUBAND 1
+
 // navigation controls and menubar just send a message to parent window
 /*
 TODO:
@@ -374,7 +376,7 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
         favoritesHMenu = GetSubMenu(parentHMenu, 3);
         if (favoritesHMenu == NULL)
             return E_FAIL;
-#if 1
+#if USE_CUSTOM_MENUBAND
         HMODULE hrs = LoadLibrary(L"rshell.dll");
 
         PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor");
@@ -553,7 +555,7 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
     HWND                                    ownerWindow;
     HRESULT                                 hResult;
 
-#if 1
+#if USE_CUSTOM_MENUBAND
     HMODULE hrs = LoadLibraryW(L"rshell.dll");
 
     if (!hrs)