[SHELL32] -CMenuBand: forward WM_WININICHANGE to CMenuToolbarBase so that when themes...
[reactos.git] / reactos / dll / win32 / shell32 / shellmenu / CMenuToolbars.cpp
index 5734673..38f8b62 100644 (file)
@@ -113,6 +113,11 @@ HRESULT CMenuToolbarBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
             return S_OK;
         }
         return S_FALSE;
+    case WM_WININICHANGE:
+        if (wParam == SPI_SETFLATMENU)
+        {
+            SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
+        }
     }
 
     return S_FALSE;
@@ -160,7 +165,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 +179,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 +211,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 +304,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 +392,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 +829,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 +841,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 +851,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 +1325,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 +1346,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);