[EXPLORER] -Reload the theme data only when the orientation changes (we ended up...
[reactos.git] / reactos / base / shell / explorer / trayntfy.cpp
index 14038fb..d91e2f5 100644 (file)
@@ -714,20 +714,19 @@ public:
                 0,
                 TMT_TEXTCOLOR,
                 &textColor);
+
+            if (this->hFont != NULL)
+                DeleteObject(this->hFont);
+
+            SetFont(hFont, FALSE);
         }
         else
         {
-            NONCLIENTMETRICS ncm = { 0 };
-            ncm.cbSize = sizeof(ncm);
-            SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE);
-
-            hFont = CreateFontIndirectW(&ncm.lfMessageFont);
-
+            /* We don't need to set a font here, our parent will use 
+              * WM_SETFONT to set the right one when themes are not enabled. */
             textColor = RGB(0, 0, 0);
         }
 
-        SetFont(hFont, FALSE);
-
         CloseThemeData(clockTheme);
 
         return TRUE;
@@ -783,7 +782,7 @@ public:
 
                 if (c > 0)
                 {
-                    /* We want a spaceing of 1/2 line */
+                    /* We want a spacing of 1/2 line */
                     LineSpacing = (LineSpacing / c) / 2;
                 }
 
@@ -867,7 +866,7 @@ public:
             if (ClockWndFormats[i].IsTime)
             {
                 iRet = GetTimeFormat(LOCALE_USER_DEFAULT,
-                    AdvancedSettings.bShowSeconds ? ClockWndFormats[i].dwFormatFlags : TIME_NOSECONDS,
+                    TaskBarSettings.bShowSeconds ? ClockWndFormats[i].dwFormatFlags : TIME_NOSECONDS,
                     &LocalTime,
                     ClockWndFormats[i].lpFormat,
                     szLines[i],
@@ -939,7 +938,7 @@ public:
         /* Calculate the due time */
         GetLocalTime(&LocalTime);
         uiDueTime = 1000 - (UINT) LocalTime.wMilliseconds;
-        if (AdvancedSettings.bShowSeconds)
+        if (TaskBarSettings.bShowSeconds)
             uiDueTime += (UINT) LocalTime.wSecond * 100;
         else
             uiDueTime += (59 - (UINT) LocalTime.wSecond) * 1000;
@@ -997,7 +996,7 @@ public:
 
         uiDueTime = CalculateDueTime();
 
-        if (AdvancedSettings.bShowSeconds)
+        if (TaskBarSettings.bShowSeconds)
         {
             uiWait1 = 1000 - 200;
             uiWait2 = 1000;
@@ -1206,8 +1205,10 @@ public:
         MESSAGE_HANDLER(WM_SIZE, OnSize)
         MESSAGE_HANDLER(WM_PAINT, OnPaint)
         MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
+        MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
         MESSAGE_HANDLER(WM_TIMER, OnTimer)
         MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)
+        MESSAGE_HANDLER(WM_SETFONT, OnSetFont)
         MESSAGE_HANDLER(TCWM_GETMINIMUMSIZE, OnGetMinimumSize)
         MESSAGE_HANDLER(TCWM_UPDATETIME, OnUpdateTime)
 
@@ -1228,10 +1229,7 @@ public:
         Create(hWndParent, 0, NULL, dwStyle);
 
         if (m_hWnd != NULL)
-        {
             SetWindowTheme(m_hWnd, L"TrayNotify", NULL);
-            OnThemeChanged();
-        }
 
         return m_hWnd;
 
@@ -1336,25 +1334,17 @@ public:
         m_pager = new CSysPagerWnd();
         m_pager->_Init(m_hWnd, !HideClock);
 
-        OnThemeChanged();
-
         return TRUE;
     }
 
-    BOOL GetMinimumSize(IN BOOL Horizontal, IN OUT PSIZE pSize)
+    BOOL GetMinimumSize(IN OUT PSIZE pSize)
     {
         SIZE szClock = { 0, 0 };
         SIZE szTray = { 0, 0 };
 
-        IsHorizontal = Horizontal;
-        if (IsHorizontal)
-            SetWindowTheme(m_hWnd, L"TrayNotifyHoriz", NULL);
-        else
-            SetWindowTheme(m_hWnd, L"TrayNotifyVert", NULL);
-
         if (!HideClock)
         {
-            if (Horizontal)
+            if (IsHorizontal)
             {
                 szClock.cy = pSize->cy - 2 * TRAY_NOTIFY_WND_SPACING_Y;
                 if (szClock.cy <= 0)
@@ -1367,7 +1357,7 @@ public:
                     goto NoClock;
             }
 
-            m_clock->SendMessage(TCWM_GETMINIMUMSIZE, (WPARAM) Horizontal, (LPARAM) &szClock);
+            m_clock->SendMessage(TCWM_GETMINIMUMSIZE, (WPARAM) IsHorizontal, (LPARAM) &szClock);
 
             szTrayClockMin = szClock;
         }
@@ -1375,7 +1365,7 @@ public:
         NoClock:
         szTrayClockMin = szClock;
 
-        if (Horizontal)
+        if (IsHorizontal)
         {
             szTray.cy = pSize->cy - 2 * TRAY_NOTIFY_WND_SPACING_Y;
         }
@@ -1384,11 +1374,11 @@ public:
             szTray.cx = pSize->cx - 2 * TRAY_NOTIFY_WND_SPACING_X;
         }
 
-        m_pager->GetSize(Horizontal, &szTray);
+        m_pager->GetSize(IsHorizontal, &szTray);
 
         szTrayNotify = szTray;
 
-        if (Horizontal)
+        if (IsHorizontal)
         {
             pSize->cx = 2 * TRAY_NOTIFY_WND_SPACING_X;
 
@@ -1515,7 +1505,18 @@ public:
 
     LRESULT OnGetMinimumSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
     {
-        return (LRESULT) GetMinimumSize((BOOL) wParam, (PSIZE) lParam);
+        BOOL Horizontal = (BOOL) wParam;
+
+        if (Horizontal != IsHorizontal)
+        {
+            IsHorizontal = Horizontal;
+            if (IsHorizontal)
+                SetWindowTheme(m_hWnd, L"TrayNotifyHoriz", NULL);
+            else
+                SetWindowTheme(m_hWnd, L"TrayNotifyVert", NULL);
+        }
+
+        return (LRESULT) GetMinimumSize((PSIZE) lParam);
     }
 
     LRESULT OnUpdateTime(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)