[EXPLORER] -Implement the trick that makes the start button to get clicked when the...
[reactos.git] / reactos / base / shell / explorer / taskswnd.cpp
index cd3cd96..1dd2bf5 100644 (file)
@@ -21,9 +21,6 @@
 #include "precomp.h"
 #include <commoncontrols.h>
 
-#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
-#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
-
 /* Set DUMP_TASKS to 1 to enable a dump of the tasks and task groups every
    5 seconds */
 #define DUMP_TASKS  0
@@ -241,8 +238,6 @@ public:
     }
     virtual ~CTaskSwitchWnd() { }
 
-    VOID TaskSwitchWnd_UpdateButtonsSize(IN BOOL bRedrawDisabled);
-
     INT GetWndTextFromTaskItem(IN PTASK_ITEM TaskItem, LPWSTR szBuf, DWORD cchBuf)
     {
         /* Get the window text without sending a message so we don't hang if an
@@ -1147,6 +1142,10 @@ public:
         LONG NewBtnSize;
         BOOL Horizontal;
 
+        int cx = GetSystemMetrics(SM_CXMINIMIZED);
+        int cy = m_ButtonSize.cy = GetSystemMetrics(SM_CYSIZE);
+        m_TaskBar.SetButtonSize(cx, cy);
+
         if (GetClientRect(&rcClient) && !IsRectEmpty(&rcClient))
         {
             if (m_ButtonCount > 0)
@@ -1160,7 +1159,11 @@ public:
                     tbm.dwMask = TBMF_BUTTONSPACING;
                     m_TaskBar.GetMetrics(&tbm);
 
-                    uiRows = (rcClient.bottom + tbm.cyButtonSpacing) / (m_ButtonSize.cy + tbm.cyButtonSpacing);
+                    if (m_ButtonSize.cy + tbm.cyButtonSpacing != 0)
+                        uiRows = (rcClient.bottom + tbm.cyButtonSpacing) / (m_ButtonSize.cy + tbm.cyButtonSpacing);
+                    else
+                        uiRows = 1;
+
                     if (uiRows == 0)
                         uiRows = 1;
 
@@ -1314,12 +1317,6 @@ public:
         m_ImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1000);
         m_TaskBar.SetImageList(m_ImageList);
 
-        /* Calculate the default button size. Don't save this in m_ButtonSize.cx so that
-        the actual button width gets updated correctly on the first recalculation */
-        int cx = GetSystemMetrics(SM_CXMINIMIZED);
-        int cy = m_ButtonSize.cy = GetSystemMetrics(SM_CYSIZE) + (2 * GetSystemMetrics(SM_CYEDGE));
-        m_TaskBar.SetButtonSize(cx, cy);
-
         /* Set proper spacing between buttons */
         m_TaskBar.UpdateTbButtonSpacing(m_Tray->IsHorizontal(), m_Theme != NULL);
 
@@ -1813,6 +1810,22 @@ public:
         return TRUE;
     }
 
+    LRESULT OnSetFont(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+    {
+        return m_TaskBar.SendMessageW(uMsg, wParam, lParam);
+    }
+
+    LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+    {
+        if (wParam == SPI_SETNONCLIENTMETRICS)
+        {
+            /*  Don't update the font, this will be done when we get a WM_SETFONT from our parent */
+            UpdateButtonsSize(FALSE);
+        }
+
+        return 0;
+    }
+
     DECLARE_WND_CLASS_EX(szTaskSwitchWndClass, CS_DBLCLKS, COLOR_3DFACE)
 
     BEGIN_MSG_MAP(CTaskSwitchWnd)
@@ -1828,6 +1841,8 @@ public:
         MESSAGE_HANDLER(TSWM_UPDATETASKBARPOS, OnUpdateTaskbarPos)
         MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
         MESSAGE_HANDLER(WM_TIMER, OnTimer)
+        MESSAGE_HANDLER(WM_SETFONT, OnSetFont)
+        MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChanged)
         MESSAGE_HANDLER(m_ShellHookMsg, HandleShellHookMsg)
     END_MSG_MAP()