[SHELL32] -CMenuBand: When the flat menus style is enabled, shell menu bars should...
[reactos.git] / reactos / dll / win32 / shell32 / shellmenu / CMenuToolbars.cpp
index 5734673..9a1a967 100644 (file)
@@ -160,7 +160,10 @@ HRESULT CMenuToolbarBase::OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResu
         isHot = m_hotBar == this && (int) cdraw->nmcd.dwItemSpec == m_hotItem;
         isPopup = m_popupBar == this && (int) cdraw->nmcd.dwItemSpec == m_popupItem;
 
-        if ((m_initFlags & SMINIT_VERTICAL))
+        if (m_hotItem < 0 && isPopup)
+            isHot = TRUE;
+
+        if ((m_useFlatMenus && isHot) || (m_initFlags & SMINIT_VERTICAL))
         {
             COLORREF clrText;
             HBRUSH   bgBrush;
@@ -171,7 +174,7 @@ HRESULT CMenuToolbarBase::OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResu
             cdraw->nmcd.uItemState &= ~(CDIS_HOT | CDIS_CHECKED);
 
             // Decide on the colors
-            if (isHot || (m_hotItem < 0 && isPopup))
+            if (isHot)
             {
                 cdraw->nmcd.uItemState |= CDIS_HOT;
 
@@ -203,7 +206,7 @@ HRESULT CMenuToolbarBase::OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT * theResu
             cdraw->nmcd.uItemState &= ~CDIS_HOT;
 
             // Decide on the colors
-            if (isHot || (m_hotItem < 0 && isPopup))
+            if (isHot)
             {
                 cdraw->nmcd.uItemState |= CDIS_HOT;
             }
@@ -296,10 +299,7 @@ HRESULT CMenuToolbarBase::ShowDW(BOOL fShow)
     UpdateImageLists();
 
     // For custom-drawing
-    if (IsAppThemed())
-        GetThemeSysBool(GetWindowTheme(m_hWnd), TMT_FLATMENUS);
-    else
-        SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
+    SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
 
     return S_OK;
 }
@@ -387,10 +387,7 @@ HRESULT CMenuToolbarBase::CreateToolbar(HWND hwndParent, DWORD dwFlags)
 
     SetWindowTheme(m_hWnd, L"", L"");
 
-    if (IsAppThemed())
-        GetThemeSysBool(GetWindowTheme(m_hWnd), TMT_FLATMENUS);
-    else
-        SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
+    SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
 
     m_menuBand->AdjustForTheme(m_useFlatMenus);
 
@@ -827,8 +824,6 @@ HRESULT CMenuToolbarBase::MenuBarMouseDown(INT iIndex, BOOL isLButton)
     TBBUTTON btn;
 
     GetButton(iIndex, &btn);
-    if (!isLButton)
-        return ProcessContextMenu(btn.idCommand);
 
     if ((m_initFlags & SMINIT_VERTICAL) 
         || m_popupBar
@@ -841,7 +836,7 @@ HRESULT CMenuToolbarBase::MenuBarMouseDown(INT iIndex, BOOL isLButton)
     return ProcessClick(btn.idCommand);
 }
 
-HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex)
+HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex, BOOL isLButton)
 {
     TBBUTTON btn;
 
@@ -851,7 +846,11 @@ HRESULT CMenuToolbarBase::MenuBarMouseUp(INT iIndex)
         return S_OK;
 
     GetButton(iIndex, &btn);
-    return ProcessClick(btn.idCommand);
+
+    if (isLButton)
+        return ProcessClick(btn.idCommand);
+    else
+        return ProcessContextMenu(btn.idCommand);
 }
 
 HRESULT CMenuToolbarBase::PrepareExecuteItem(INT iItem)
@@ -1321,6 +1320,7 @@ HRESULT CMenuSFToolbar::FillToolbar(BOOL clearFirst)
     // If no items were added, show the "empty" placeholder
     if (DPA_GetPtrCount(dpaSort) == 0)
     {
+        DPA_Destroy(dpaSort);
         return AddPlaceholder();
     }
 
@@ -1341,7 +1341,10 @@ HRESULT CMenuSFToolbar::FillToolbar(BOOL clearFirst)
 
         hr = m_shellFolder->GetDisplayNameOf(item, SIGDN_NORMALDISPLAY, &sr);
         if (FAILED_UNEXPECTEDLY(hr))
+        {
+            DPA_Destroy(dpaSort);
             return hr;
+        }
 
         StrRetToStr(&sr, NULL, &MenuString);