mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 23:33:24 +08:00
[EXPLORER] Show time and date when two lines are available in the taskbar clock area (#5410)
- Add registry key to show the time and date when two lines are available in the taskbar clock area. - Keep old behavior when `PreferDateOverWeekday` registry key in `HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced` is set to 0 or not present. When three or more lines are available, the clock will continue to show the time, day of the week, and the date. When only one line is visible, the clock will continue to only display the time. CORE-19018
This commit is contained in:
committed by
GitHub
parent
ebb7c0524b
commit
19c8574ec8
@@ -38,6 +38,9 @@ const struct
|
||||
const UINT ClockWndFormatsCount = _ARRAYSIZE(ClockWndFormats);
|
||||
|
||||
#define CLOCKWND_FORMAT_COUNT ClockWndFormatsCount
|
||||
#define CLOCKWND_FORMAT_TIME 0
|
||||
#define CLOCKWND_FORMAT_DAY 1
|
||||
#define CLOCKWND_FORMAT_DATE 2
|
||||
|
||||
static const WCHAR szTrayClockWndClass[] = L"TrayClockWClass";
|
||||
|
||||
@@ -98,6 +101,7 @@ private:
|
||||
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
VOID PaintLine(IN HDC hDC, IN OUT RECT *rcClient, IN UINT LineNumber, IN UINT szLinesIndex);
|
||||
|
||||
public:
|
||||
|
||||
@@ -529,19 +533,20 @@ LRESULT CTrayClockWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||
rcClient.top = (rcClient.bottom - CurrentSize.cy) / 2;
|
||||
rcClient.bottom = rcClient.top + CurrentSize.cy;
|
||||
|
||||
for (i = 0, line = 0;
|
||||
i < CLOCKWND_FORMAT_COUNT && line < VisibleLines;
|
||||
i++)
|
||||
if (VisibleLines == 2)
|
||||
{
|
||||
if (LineSizes[i].cx != 0)
|
||||
/* Display either time and weekday (by default), or time and date (opt-in) */
|
||||
PaintLine(hDC, &rcClient, 0, CLOCKWND_FORMAT_TIME);
|
||||
PaintLine(hDC, &rcClient, 1,
|
||||
g_TaskbarSettings.bPreferDate ? CLOCKWND_FORMAT_DATE : CLOCKWND_FORMAT_DAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0, line = 0;
|
||||
i < CLOCKWND_FORMAT_COUNT && line < VisibleLines;
|
||||
i++)
|
||||
{
|
||||
TextOut(hDC,
|
||||
(rcClient.right - LineSizes[i].cx) / 2,
|
||||
rcClient.top + TRAY_CLOCK_WND_SPACING_Y,
|
||||
szLines[i],
|
||||
wcslen(szLines[i]));
|
||||
|
||||
rcClient.top += LineSizes[i].cy + LineSpacing;
|
||||
PaintLine(hDC, &rcClient, i, i);
|
||||
line++;
|
||||
}
|
||||
}
|
||||
@@ -557,6 +562,20 @@ LRESULT CTrayClockWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID CTrayClockWnd::PaintLine(IN HDC hDC, IN OUT RECT *rcClient, IN UINT LineNumber, IN UINT szLinesIndex)
|
||||
{
|
||||
if (LineSizes[LineNumber].cx == 0)
|
||||
return;
|
||||
|
||||
TextOut(hDC,
|
||||
(rcClient->right - LineSizes[szLinesIndex].cx) / 2,
|
||||
rcClient->top + TRAY_CLOCK_WND_SPACING_Y,
|
||||
szLines[szLinesIndex],
|
||||
wcslen(szLines[szLinesIndex]));
|
||||
|
||||
rcClient->top += LineSizes[LineNumber].cy + LineSpacing;
|
||||
}
|
||||
|
||||
VOID CTrayClockWnd::SetFont(IN HFONT hNewFont, IN BOOL bRedraw)
|
||||
{
|
||||
hFont = hNewFont;
|
||||
@@ -704,6 +723,12 @@ LRESULT CTrayClockWnd::OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM
|
||||
}
|
||||
}
|
||||
|
||||
if (newSettings->bPreferDate != g_TaskbarSettings.bPreferDate)
|
||||
{
|
||||
g_TaskbarSettings.bPreferDate = newSettings->bPreferDate;
|
||||
bRealign = TRUE;
|
||||
}
|
||||
|
||||
if (bRealign)
|
||||
{
|
||||
/* Ask the parent to resize */
|
||||
|
||||
Reference in New Issue
Block a user