#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
return SetButtonInfo(iButtonIndex, &tbbi) != 0;
}
+ LRESULT OnNcHitTestToolbar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ POINT pt;
+
+ /* See if the mouse is on a button */
+ pt.x = GET_X_LPARAM(lParam);
+ pt.y = GET_Y_LPARAM(lParam);
+ ScreenToClient(&pt);
+
+ INT index = HitTest(&pt);
+ if (index < 0)
+ {
+ /* Make the control appear to be transparent outside of any buttons */
+ return HTTRANSPARENT;
+ }
+
+ bHandled = FALSE;
+ return 0;
+ }
+
public:
BEGIN_MSG_MAP(CNotifyToolbar)
+ MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTestToolbar)
END_MSG_MAP()
BOOL Initialize(HWND hWndParent)
}
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
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)
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;
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);
switch ((INT) wParam)
{
case HSHELL_APPCOMMAND:
- HandleAppCommand(wParam, lParam);
- Ret = TRUE;
+ Ret = HandleAppCommand(wParam, lParam);
break;
case HSHELL_WINDOWCREATED:
- Ret = AddTask((HWND) lParam);
+ AddTask((HWND) lParam);
break;
case HSHELL_WINDOWDESTROYED:
/* The window still exists! Delay destroying it a bit */
DeleteTask((HWND) lParam);
- Ret = TRUE;
break;
case HSHELL_RUDEAPPACTIVATED:
case HSHELL_WINDOWACTIVATED:
- if (lParam)
- {
- ActivateTask((HWND) lParam);
- Ret = TRUE;
- }
+ ActivateTask((HWND) lParam);
break;
case HSHELL_FLASH:
FlashTask((HWND) lParam);
- Ret = TRUE;
break;
case HSHELL_REDRAW:
RedrawTask((HWND) lParam);
- Ret = TRUE;
break;
case HSHELL_TASKMAN:
{
m_IsGroupingEnabled = bEnable;
- /* Collapse or expand groups if neccessary */
+ /* Collapse or expand groups if necessary */
UpdateButtonsSize(FALSE);
}
VOID HandleTaskItemRightClick(IN OUT PTASK_ITEM TaskItem)
{
+ POINT pt;
+ GetCursorPos(&pt);
- HMENU hmenu = ::GetSystemMenu(TaskItem->hWnd, FALSE);
+ SetForegroundWindow(TaskItem->hWnd);
- if (hmenu)
- {
- POINT pt;
- int cmd;
- GetCursorPos(&pt);
- cmd = TrackPopupMenu(hmenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_TaskBar.m_hWnd, NULL);
- if (cmd)
- {
- SetForegroundWindow(TaskItem->hWnd); // reactivate window after the context menu has closed
- ::PostMessage(TaskItem->hWnd, WM_SYSCOMMAND, cmd, 0);
- }
- }
+ ActivateTask(TaskItem->hWnd);
+
+ ::SendMessageW(TaskItem->hWnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y));
}
VOID HandleTaskGroupRightClick(IN OUT PTASK_GROUP TaskGroup)
if (TaskItem != NULL && ::IsWindow(TaskItem->hWnd))
{
- /* Make the entire button flashing if neccessary */
+ /* Make the entire button flashing if necessary */
if (nmtbcd->nmcd.uItemState & CDIS_MARKED)
{
Ret = TBCDRF_NOBACKGROUND;
return TRUE;
}
- LRESULT OnNcHitTestToolbar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- POINT pt;
-
- /* See if the mouse is on a button */
- pt.x = GET_X_LPARAM(lParam);
- pt.y = GET_Y_LPARAM(lParam);
- ScreenToClient(&pt);
-
- INT index = m_TaskBar.HitTest(&pt);
- if (index < 0)
- {
- /* Make the control appear to be transparent outside of any buttons */
- return HTTRANSPARENT;
- }
-
- bHandled = FALSE;
- return 0;
- }
-
LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
LRESULT Ret = TRUE;
return FALSE;
}
+ LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ return MA_NOACTIVATE;
+ }
+
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
#if DUMP_TASKS != 0
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)
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)
- ALT_MSG_MAP(1)
- MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTestToolbar)
+ MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
+ MESSAGE_HANDLER(WM_KLUDGEMINRECT, OnKludgeItemRect)
END_MSG_MAP()
HWND _Init(IN HWND hWndParent, IN OUT ITrayWindow *tray)