/*
* SysPagerWnd
*/
-static const WCHAR szSysPagerWndClass [] = TEXT("SysPager");
+static const WCHAR szSysPagerWndClass [] = L"SysPager";
// Data comes from shell32/systray.cpp -> TrayNotifyCDS_Dummy
typedef struct _SYS_PAGER_COPY_DATA
{
TBBUTTON tbBtn;
NOTIFYICONDATA * notifyItem;
- WCHAR text [] = TEXT("");
+ WCHAR text[] = L"";
int index = FindItemByIconData(iconData, ¬ifyItem);
if (index >= 0)
Toolbar.Initialize(m_hWnd);
// Explicitly request running applications to re-register their systray icons
- ::SendNotifyMessage(HWND_BROADCAST,
- RegisterWindowMessage(TEXT("TaskbarCreated")),
- 0,
- 0);
+ ::SendNotifyMessageW(HWND_BROADCAST,
+ RegisterWindowMessageW(L"TaskbarCreated"),
+ 0, 0);
return TRUE;
}
* TrayClockWnd
*/
-static const WCHAR szTrayClockWndClass [] = TEXT("TrayClockWClass");
+static const WCHAR szTrayClockWndClass[] = L"TrayClockWClass";
#define ID_TRAYCLOCK_TIMER 0
#define ID_TRAYCLOCK_TIMER_INIT 1
{
BOOL IsTime;
DWORD dwFormatFlags;
- LPCTSTR lpFormat;
+ LPCWSTR lpFormat;
} ClockWndFormats [] = {
- { TRUE, 0, NULL },
- { FALSE, 0, TEXT("dddd") },
- { FALSE, DATE_SHORTDATE, NULL }
+ { TRUE, 0, NULL },
+ { FALSE, 0, L"dddd" },
+ { FALSE, DATE_SHORTDATE, NULL }
};
-#define CLOCKWND_FORMAT_COUNT (sizeof(ClockWndFormats) / sizeof(ClockWndFormats[0]))
+#define CLOCKWND_FORMAT_COUNT (_ARRAYSIZE(ClockWndFormats))
#define TRAY_CLOCK_WND_SPACING_X 0
#define TRAY_CLOCK_WND_SPACING_Y 0
ZeroMemory(&LocalTime, sizeof(LocalTime));
ZeroMemory(&CurrentSize, sizeof(CurrentSize));
ZeroMemory(LineSizes, sizeof(LineSizes));
- ZeroMemory(szLines, sizeof(LineSizes));
+ ZeroMemory(szLines, sizeof(szLines));
}
virtual ~CTrayClockWnd() { }
0,
TMT_TEXTCOLOR,
&textColor);
+
+ if (this->hFont != NULL)
+ DeleteObject(this->hFont);
+
+ SetFont(hFont, FALSE);
}
else
{
- NONCLIENTMETRICS ncm = { 0 };
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(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;
{
HDC hDC;
HFONT hPrevFont;
- INT c, i;
+ UINT c, i;
BOOL bRet = TRUE;
hDC = GetDC();
if (hFont)
hPrevFont = (HFONT) SelectObject(hDC, hFont);
- for (i = 0; i != CLOCKWND_FORMAT_COUNT && bRet; i++)
+ for (i = 0; i < CLOCKWND_FORMAT_COUNT && bRet; i++)
{
- if (szLines[i][0] != TEXT('\0') &&
- !GetTextExtentPoint(hDC, szLines[i], _tcslen(szLines[i]),
- &LineSizes[i]))
+ if (szLines[i][0] != L'\0' &&
+ !GetTextExtentPointW(hDC, szLines[i], wcslen(szLines[i]),
+ &LineSizes[i]))
{
bRet = FALSE;
break;
LineSpacing = 0;
/* calculate the line spacing */
- for (i = 0, c = 0; i != CLOCKWND_FORMAT_COUNT; i++)
+ for (i = 0, c = 0; i < CLOCKWND_FORMAT_COUNT; i++)
{
if (LineSizes[i].cx > 0)
{
if (c > 0)
{
- /* We want a spaceing of 1/2 line */
+ /* We want a spacing of 1/2 line */
LineSpacing = (LineSpacing / c) / 2;
}
WORD GetMinimumSize(IN BOOL Horizontal, IN OUT PSIZE pSize)
{
WORD iLinesVisible = 0;
- INT i;
+ UINT i;
SIZE szMax = { 0, 0 };
if (!LinesMeasured)
if (!LinesMeasured)
return 0;
- for (i = 0;
- i != CLOCKWND_FORMAT_COUNT;
- i++)
+ for (i = 0; i < CLOCKWND_FORMAT_COUNT; i++)
{
if (LineSizes[i].cx != 0)
{
}
- VOID UpdateWnd()
+ VOID UpdateWnd()
{
SIZE szPrevCurrent;
- INT BufSize, iRet, i;
+ UINT BufSize, i;
+ INT iRet;
RECT rcClient;
- ZeroMemory(LineSizes,
- sizeof(LineSizes));
+ ZeroMemory(LineSizes, sizeof(LineSizes));
szPrevCurrent = CurrentSize;
- for (i = 0;
- i != CLOCKWND_FORMAT_COUNT;
- i++)
+ for (i = 0; i < CLOCKWND_FORMAT_COUNT; i++)
{
- szLines[i][0] = TEXT('\0');
- BufSize = sizeof(szLines[0]) / sizeof(szLines[0][0]);
+ szLines[i][0] = L'\0';
+ BufSize = _countof(szLines[0]);
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],
}
}
- VOID Update()
+ VOID Update()
{
GetLocalTime(&LocalTime);
UpdateWnd();
}
- UINT CalculateDueTime()
+ UINT CalculateDueTime()
{
UINT uiDueTime;
/* 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;
return uiDueTime;
}
- BOOL ResetTime()
+ BOOL ResetTime()
{
UINT uiDueTime;
BOOL Ret;
return Ret;
}
- VOID CalibrateTimer()
+ VOID CalibrateTimer()
{
UINT uiDueTime;
BOOL Ret;
uiDueTime = CalculateDueTime();
- if (AdvancedSettings.bShowSeconds)
+ if (TaskBarSettings.bShowSeconds)
{
uiWait1 = 1000 - 200;
uiWait2 = 1000;
{
RECT rcClient;
HFONT hPrevFont;
- int iPrevBkMode, i, line;
+ INT iPrevBkMode;
+ UINT i, line;
PAINTSTRUCT ps;
HDC hDC = (HDC) wParam;
rcClient.bottom = rcClient.top + CurrentSize.cy;
for (i = 0, line = 0;
- i != CLOCKWND_FORMAT_COUNT && line < VisibleLines;
- i++)
+ i < CLOCKWND_FORMAT_COUNT && line < VisibleLines;
+ i++)
{
if (LineSizes[i].cx != 0)
{
TRAY_CLOCK_WND_SPACING_X,
rcClient.top + TRAY_CLOCK_WND_SPACING_Y,
szLines[i],
- _tcslen(szLines[i]));
+ wcslen(szLines[i]));
rcClient.top += LineSizes[i].cy + LineSpacing;
line++;
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)
Create(hWndParent, 0, NULL, dwStyle);
if (m_hWnd != NULL)
- {
SetWindowTheme(m_hWnd, L"TrayNotify", NULL);
- OnThemeChanged();
- }
return m_hWnd;
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)
goto NoClock;
}
- m_clock->SendMessage(TCWM_GETMINIMUMSIZE, (WPARAM) Horizontal, (LPARAM) &szClock);
+ m_clock->SendMessage(TCWM_GETMINIMUMSIZE, (WPARAM) IsHorizontal, (LPARAM) &szClock);
szTrayClockMin = szClock;
}
NoClock:
szTrayClockMin = szClock;
- if (Horizontal)
+ if (IsHorizontal)
{
szTray.cy = pSize->cy - 2 * TRAY_NOTIFY_WND_SPACING_Y;
}
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;
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)