[BROWSEUI]
authorDavid Quintana <gigaherz@gmail.com>
Wed, 12 Nov 2014 17:13:05 +0000 (17:13 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Wed, 12 Nov 2014 17:13:05 +0000 (17:13 +0000)
* Remove the unwanted "(Empty)" item from the static menu, the SF menu will add its own if needed.

[RSHELL]
* Load the "(Empty)" string from shell32 resources.

[SHELL32]
* Add the string resource for empty menus.

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

base/shell/explorer-new/traywnd.cpp
base/shell/rshell/CMenuBand.cpp
base/shell/rshell/CMenuToolbars.cpp
dll/win32/browseui/internettoolbar.cpp
dll/win32/browseui/shellbrowser.cpp
dll/win32/shell32/lang/en-US.rc
dll/win32/shell32/shresdef.h

index 1c143fb..322c62e 100644 (file)
@@ -1345,8 +1345,7 @@ DefSize:
         /* Make sure the height is at least the size of a caption icon. */
         if (hIconStart != NULL)
             Size.cx += SmallIcon.cx + 4;
-        Size.cy = max(Size.cy,
-                      SmallIcon.cy);
+        Size.cy = max(Size.cy, SmallIcon.cy);
 
         /* Create the bitmap */
         hbmp = CreateCompatibleBitmap(hDCScreen,
index 160df00..e010637 100644 (file)
@@ -132,7 +132,7 @@ HRESULT STDMETHODCALLTYPE  CMenuBand::SetMenu(
 
     BOOL created = FALSE;
 
-    if (m_hmenu)
+    if (m_hmenu && m_hmenu != hmenu)
     {
         DestroyMenu(m_hmenu);
         m_hmenu = NULL;
index 3985ab6..11f6de4 100644 (file)
@@ -25,6 +25,8 @@
 #include "CMenuBand.h"
 #include "CMenuToolbars.h"
 
+#define IDS_MENU_EMPTY 34561
+
 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
 
@@ -425,14 +427,19 @@ HRESULT CMenuToolbarBase::GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegr
     if (m_hasSizes)
         return S_OK;
 
+    TRACE("Sizes out of date, recalculating.\n");
+
     if (!m_hWnd)
+    {
         return S_OK;
+    }
 
     // Obtain the ideal size, to be used as min and max
-    AutoSize();
     GetMaxSize(&m_idealSize);
     GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);
 
+    TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());
+
     // Obtain the button size, to be used as the integral size
     DWORD size = GetButtonSize();
     m_itemSize.cx = GET_X_LPARAM(size);
@@ -1004,7 +1011,9 @@ HRESULT CMenuToolbarBase::AddSeparator(BOOL last)
 HRESULT CMenuToolbarBase::AddPlaceholder()
 {
     TBBUTTON tbb = { 0 };
-    PCWSTR MenuString = L"(Empty)"; // FIXME: Make localizable
+    WCHAR MenuString[128];
+    
+    LoadStringW(GetModuleHandle(L"shell32.dll"), IDS_MENU_EMPTY, MenuString, _countof(MenuString));
 
     tbb.fsState = 0;
     tbb.fsStyle = 0;
@@ -1131,6 +1140,8 @@ HRESULT  CMenuStaticToolbar::SetMenu(
     m_hwndMenu = hwnd;
     m_dwMenuFlags = dwFlags;
 
+    ClearToolbar();
+
     return S_OK;
 }
 
@@ -1340,6 +1351,9 @@ HRESULT CMenuSFToolbar::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFold
     m_idList = ILClone(pidlFolder);
     m_hKey = hKey;
     m_dwMenuFlags = dwFlags;
+
+    ClearToolbar();
+
     return S_OK;
 }
 
index b7803c7..e536baa 100644 (file)
@@ -547,18 +547,19 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
     if (psmd->uId != FCIDM_MENU_FAVORITES)
         return E_FAIL;
 
+    // create favorites menu
+    hResult = psmd->punk->QueryInterface(IID_PPV_ARG(IShellMenu, &parentMenu));
+    if (FAILED_UNEXPECTEDLY(hResult))
+        return hResult;
+    hResult = parentMenu->GetMenu(&parentHMenu, &ownerWindow, NULL);
+    if (FAILED_UNEXPECTEDLY(hResult))
+        return hResult;
+    favoritesHMenu = GetSubMenu(parentHMenu, 3);
+    if (favoritesHMenu == NULL)
+        return E_FAIL;
+
     if (fFavoritesMenu.p == NULL)
     {
-        // create favorites menu
-        hResult = psmd->punk->QueryInterface(IID_PPV_ARG(IShellMenu, &parentMenu));
-        if (FAILED_UNEXPECTEDLY(hResult))
-            return hResult;
-        hResult = parentMenu->GetMenu(&parentHMenu, &ownerWindow, NULL);
-        if (FAILED_UNEXPECTEDLY(hResult))
-            return hResult;
-        favoritesHMenu = GetSubMenu(parentHMenu, 3);
-        if (favoritesHMenu == NULL)
-            return E_FAIL;
 #if USE_CUSTOM_MENUBAND
         if (!hRShell)
         {
@@ -586,9 +587,6 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
         if (FAILED_UNEXPECTEDLY(hResult))
             return hResult;
         hResult = newMenu->Initialize(this, FCIDM_MENU_FAVORITES, -1, SMINIT_VERTICAL | SMINIT_CACHED);
-        if (FAILED_UNEXPECTEDLY(hResult))
-            return hResult;
-        hResult = newMenu->SetMenu(favoritesHMenu, ownerWindow, SMSET_TOP | SMSET_DONTOWN);
         if (FAILED_UNEXPECTEDLY(hResult))
             return hResult;
 
@@ -609,6 +607,10 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, v
         fFavoritesMenu = newMenu;
     }
 
+    hResult = fFavoritesMenu->SetMenu(favoritesHMenu, ownerWindow, SMSET_TOP | SMSET_DONTOWN);
+    if (FAILED_UNEXPECTEDLY(hResult))
+        return hResult;
+
     return fFavoritesMenu->QueryInterface(riid, ppvObject);
 }
 
@@ -794,7 +796,16 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **pMenuBar)
         if (FAILED_UNEXPECTEDLY(hResult))
             return hResult;
 
-        hResult = menubar->SetMenu((HMENU) V_INTREF(&menuOut), ownerWindow, SMSET_DONTOWN);
+        HMENU hMenuBar = (HMENU) V_INTREF(&menuOut);
+
+        // FIXME: Figure out the proper way to do this.
+        HMENU hMenuFavs = GetSubMenu(hMenuBar, 3);
+        if (hMenuFavs)
+        {
+            DeleteMenu(hMenuFavs, IDM_FAVORITES_EMPTY, MF_BYCOMMAND);
+        }
+
+        hResult = menubar->SetMenu(hMenuBar, ownerWindow, SMSET_DONTOWN);
         if (FAILED_UNEXPECTEDLY(hResult))
             return hResult;
     }
index 22efd29..59691cc 100644 (file)
@@ -1874,6 +1874,17 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU h
     hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
+
+    if (hmenuShared)
+    {
+        // FIXME: Figure out the proper way to do this.
+        HMENU hMenuFavs = GetSubMenu(hmenuShared, 3);
+        if (hMenuFavs)
+        {
+            DeleteMenu(hMenuFavs, IDM_FAVORITES_EMPTY, MF_BYCOMMAND);
+        }
+    }
+
     hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN);
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
index 2ab2a25..c5c3143 100644 (file)
@@ -798,4 +798,6 @@ BEGIN
     IDS_BYTES_FORMAT "bytes"
     IDS_UNKNOWN_APP "Unknown application"
     IDS_EXE_DESCRIPTION "Description:"
+
+    IDS_MENU_EMPTY "(Empty)"
 END
index 4fecf9b..0e9b0c8 100644 (file)
 #define IDS_DESCRIPTION          331
 #define IDS_COPY_OF              332
 
+#define IDS_MENU_EMPTY           34561
+
 /* Note: those strings are referenced from the registry */
 #define IDS_RECYCLEBIN_FOLDER_NAME 8964
 #define IDS_ADMINISTRATIVETOOLS    22982