}
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) + (2 * GetSystemMetrics(SM_CYEDGE));
+ m_TaskBar.SetButtonSize(cx, cy);
+
if (GetClientRect(&rcClient) && !IsRectEmpty(&rcClient))
{
if (m_ButtonCount > 0)
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);
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)
END_MSG_MAP()
#define IDHK_DESKTOP 0x1fe
#define IDHK_PAGER 0x1ff
-static LONG TrayWndCount = 0;
-
static const WCHAR szTrayWndClass[] = L"Shell_TrayWnd";
/*
DeleteObject(m_Font);
}
- HFONT GetFont()
- {
- return m_Font;
- }
-
SIZE GetSize()
{
return m_Size;
}
- VOID UpdateSize(IN HBITMAP hbmStart = NULL)
+ VOID UpdateSize()
{
SIZE Size = { 0, 0 };
!SendMessageW(BCM_GETIDEALSIZE, 0, (LPARAM) &Size))
{
Size.cx = 2 * GetSystemMetrics(SM_CXEDGE) + GetSystemMetrics(SM_CYCAPTION) * 3;
- Size.cy = 2 * GetSystemMetrics(SM_CYEDGE) + GetSystemMetrics(SM_CYCAPTION);
}
+ if (GetWindowTheme(m_hWnd))
+ Size.cy = max(Size.cy, GetSystemMetrics(SM_CYCAPTION));
+ else
+ Size.cy = max(Size.cy, GetSystemMetrics(SM_CYSIZE) + (2 * GetSystemMetrics(SM_CYEDGE)));
+
/* Save the size of the start button */
m_Size = Size;
}
- VOID Initialize()
+ VOID UpdateFont()
{
- SetWindowTheme(m_hWnd, L"Start", NULL);
-
/* Get the system fonts, we use the caption font, always bold, though. */
NONCLIENTMETRICS ncm = {sizeof(ncm)};
- if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
- {
- ncm.lfCaptionFont.lfWeight = FW_BOLD;
- m_Font = CreateFontIndirect(&ncm.lfCaptionFont);
- }
+ if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
+ return;
+
+ if (m_Font)
+ DeleteObject(m_Font);
+
+ ncm.lfCaptionFont.lfWeight = FW_BOLD;
+ m_Font = CreateFontIndirect(&ncm.lfCaptionFont);
SetFont(m_Font, FALSE);
+ }
+
+ VOID Initialize()
+ {
+ SetWindowTheme(m_hWnd, L"Start", NULL);
m_ImageList = ImageList_LoadImageW(hExplorerInstance,
MAKEINTRESOURCEW(IDB_START),
HTHEME m_Theme;
- HFONT m_CaptionFont;
HFONT m_Font;
HWND m_DesktopWnd;
CTrayWindow() :
m_StartButton(),
m_Theme(NULL),
- m_CaptionFont(NULL),
m_Font(NULL),
m_DesktopWnd(NULL),
m_Rebar(NULL),
m_ShellServices = NULL;
}
- if (m_CaptionFont != NULL)
- {
- DeleteObject(m_CaptionFont);
- m_CaptionFont = NULL;
- }
-
if (m_Font != NULL)
{
DeleteObject(m_Font);
m_Theme = NULL;
}
- if (InterlockedDecrement(&TrayWndCount) == 0)
- PostQuitMessage(0);
+ PostQuitMessage(0);
}
* ##### moving and sizing handling #####
*/
- BOOL UpdateNonClientMetrics()
+ void UpdateFonts()
{
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(ncm);
- if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
- {
- if (m_Font != NULL)
- DeleteObject(m_Font);
+ m_StartButton.UpdateFont();
- m_Font = CreateFontIndirect(&ncm.lfMessageFont);
- return TRUE;
+ NONCLIENTMETRICS ncm = {sizeof(ncm)};
+ if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
+ {
+ ERR("SPI_GETNONCLIENTMETRICS failed\n");
+ return;
}
- return FALSE;
- }
+ if (m_Font != NULL)
+ DeleteObject(m_Font);
- VOID SetWindowsFont()
- {
- if (m_TrayNotify != NULL)
+ ncm.lfCaptionFont.lfWeight = FW_NORMAL;
+ m_Font = CreateFontIndirect(&ncm.lfCaptionFont);
+ if (!m_Font)
{
- SendMessage(m_TrayNotify, WM_SETFONT, (WPARAM) m_Font, TRUE);
+ ERR("CreateFontIndirect failed\n");
+ return;
}
+
+ SendMessage(m_Rebar, WM_SETFONT, (WPARAM) m_Font, TRUE);
+ SendMessage(m_TaskSwitch, WM_SETFONT, (WPARAM) m_Font, TRUE);
+ SendMessage(m_TrayNotify, WM_SETFONT, (WPARAM) m_Font, TRUE);
}
HMONITOR GetScreenRectFromRect(
rcTray.bottom += m_AutoHideOffset.cy;
}
+ IUnknown_Exec(m_TrayBandSite,
+ IID_IDeskBand,
+ DBID_BANDINFOCHANGED,
+ 0,
+ NULL,
+ NULL);
+
+ FitToRebar(&rcTray);
+ m_TrayRects[m_Position] = rcTray;
+
/* Move the tray window */
SetWindowPos(NULL,
rcTray.left,
}
}
+ void FitToRebar(PRECT pRect)
+ {
+ /* Get the rect of the rebar */
+ RECT rebarRect, taskbarRect;
+ ::GetWindowRect(m_Rebar, &rebarRect);
+ ::GetWindowRect(m_hWnd, &taskbarRect);
+ OffsetRect(&rebarRect, -taskbarRect.left, -taskbarRect.top);
+
+ /* Calculate the difference of size of the taskbar and the rebar */
+ SIZE margins;
+ margins.cx = taskbarRect.right - taskbarRect.left - rebarRect.right + rebarRect.left;
+ margins.cy = taskbarRect.bottom - taskbarRect.top - rebarRect.bottom + rebarRect.top;
+
+ /* Calculate the new size of the rebar and make it resize, then change the new taskbar size */
+ switch (m_Position)
+ {
+ case ABE_TOP:
+ rebarRect.bottom = rebarRect.top + pRect->bottom - pRect->top - margins.cy;
+ ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
+ pRect->bottom = pRect->top + rebarRect.bottom - rebarRect.top + margins.cy;
+ break;
+ case ABE_BOTTOM:
+ rebarRect.top = rebarRect.bottom - (pRect->bottom - pRect->top - margins.cy);
+ ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
+ ERR("rebarRect: %d, %d, %d,%d\n", rebarRect.top, rebarRect.left, rebarRect.right, rebarRect.bottom);
+ pRect->top = pRect->bottom - (rebarRect.bottom - rebarRect.top + margins.cy);
+ break;
+ case ABE_LEFT:
+ case ABE_RIGHT:
+ /* FIXME: what to do here? */
+ break;
+ }
+
+ CalculateValidSize(m_Position, pRect);
+ }
+
void PopupStartMenu()
{
if (m_StartMenuPopup != NULL)
If it was somehow destroyed just create a new tray window. */
if (m_hWnd != NULL && IsWindow())
{
- if (!IsWindowVisible())
- {
- CheckTrayWndPosition();
-
- ShowWindow(SW_SHOW);
- }
-
return S_OK;
}
if (!Create(NULL, rcWnd, NULL, dwStyle, dwExStyle))
return E_FAIL;
+ /* Align all controls on the tray window */
+ AlignControls(NULL);
+
+ /* Move the tray window to the right position and resize it if necessary */
+ CheckTrayWndPosition();
+
return S_OK;
}
return IsPosHorizontal();
}
- HFONT STDMETHODCALLTYPE GetCaptionFonts(OUT HFONT *phBoldCaption OPTIONAL)
- {
- if (phBoldCaption != NULL)
- *phBoldCaption = m_StartButton.GetFont();
-
- return m_CaptionFont;
- }
-
BOOL STDMETHODCALLTYPE Lock(IN BOOL bLock)
{
BOOL bPrevLock = Locked;
}
}
SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
+ ResizeWorkArea();
+ ApplyClipping(TRUE);
}
return bPrevLock;
SetWindowTheme(m_hWnd, L"TaskBar", NULL);
- InterlockedIncrement(&TrayWndCount);
-
- if (m_CaptionFont == NULL)
- {
- NONCLIENTMETRICS ncm;
-
- /* Get the system fonts, we use the caption font,
- always bold, though. */
- ncm.cbSize = sizeof(ncm);
- if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, FALSE))
- {
- if (m_CaptionFont == NULL)
- {
- ncm.lfCaptionFont.lfWeight = FW_NORMAL;
- m_CaptionFont = CreateFontIndirect(&ncm.lfCaptionFont);
- }
- }
- }
-
/* Create the Start button */
m_StartButton.Create(m_hWnd);
HBITMAP hbmBanner = LoadBitmapW(hExplorerInstance, MAKEINTRESOURCEW(IDB_STARTMENU));
m_StartMenuPopup = CreateStartMenu(this, &m_StartMenuBand, hbmBanner, 0);
- /* Load the tray band site */
+ /* Create the tray band site and its rebar */
m_TrayBandSite = CreateTrayBandSite(this, &m_Rebar, &m_TaskSwitch);
SetWindowTheme(m_Rebar, L"TaskBar", NULL);
/* Create the tray notification window */
m_TrayNotify = CreateTrayNotifyWnd(this, HideClock, &m_TrayNotifyInstance);
- if (UpdateNonClientMetrics())
- {
- SetWindowsFont();
- }
-
- /* Move the tray window to the right position and resize it if necessary */
- CheckTrayWndPosition();
-
- /* Align all controls on the tray window */
- AlignControls(NULL);
+ UpdateFonts();
InitShellServices(&m_ShellServices);
return TRUE;
}
+ LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ if (wParam == SPI_SETNONCLIENTMETRICS)
+ {
+ SendMessage(m_TaskSwitch, uMsg, wParam, lParam);
+ UpdateFonts();
+ AlignControls(NULL);
+ CheckTrayWndPosition();
+ }
+
+ return 0;
+ }
+
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HDC hdc = (HDC) wParam;
LRESULT OnDisplayChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
- /* Load the saved tray window settings */
- RegLoadSettings();
-
/* Move the tray window to the right position and resize it if necessary */
CheckTrayWndPosition();
- /* Align all controls on the tray window */
- AlignControls(NULL);
-
return TRUE;
}
if (!Locked)
{
- /* Get the rect of the rebar */
- RECT rebarRect, taskbarRect;
- ::GetWindowRect(m_Rebar, &rebarRect);
- ::GetWindowRect(m_hWnd, &taskbarRect);
- OffsetRect(&rebarRect, -taskbarRect.left, -taskbarRect.top);
-
- /* Calculate the difference of size of the taskbar and the rebar */
- SIZE margins;
- margins.cx = taskbarRect.right - taskbarRect.left - rebarRect.right + rebarRect.left;
- margins.cy = taskbarRect.bottom - taskbarRect.top - rebarRect.bottom + rebarRect.top;
-
- /* Calculate the new size of the rebar and make it resize, then change the new taskbar size */
- switch (m_Position)
- {
- case ABE_TOP:
- rebarRect.bottom = rebarRect.top + pRect->bottom - pRect->top - margins.cy;
- ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
- pRect->bottom = pRect->top + rebarRect.bottom - rebarRect.top + margins.cy;
- break;
- case ABE_BOTTOM:
- rebarRect.top = rebarRect.bottom - (pRect->bottom - pRect->top - margins.cy);
- ::SendMessageW(m_Rebar, RB_SIZETORECT, RBSTR_CHANGERECT, (LPARAM)&rebarRect);
- pRect->top = pRect->bottom - (rebarRect.bottom - rebarRect.top + margins.cy);
- break;
- case ABE_LEFT:
- case ABE_RIGHT:
- /* FIXME: what to do here? */
- break;
- }
-
- CalculateValidSize(m_Position, pRect);
+ FitToRebar(pRect);
}
else
{
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
RECT rcClient;
- InvalidateRect(NULL, TRUE);
if (wParam == SIZE_RESTORED && lParam == 0)
{
ResizeWorkArea();
lParam = Msg.lParam;
}
MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
+ MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChanged)
NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, OnRebarAutoSize) // Doesn't quite work ;P
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
MESSAGE_HANDLER(WM_SIZE, OnSize)