mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00: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:
parent
ebb7c0524b
commit
19c8574ec8
4 changed files with 42 additions and 11 deletions
|
@ -208,6 +208,7 @@ struct TaskbarSettings
|
|||
BOOL bLock;
|
||||
BOOL bGroupButtons;
|
||||
BOOL bShowSeconds;
|
||||
BOOL bPreferDate;
|
||||
BOOL bHideInactiveIcons;
|
||||
TW_STRUCKRECTS2 sr;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ TaskbarSettings g_TaskbarSettings;
|
|||
BOOL TaskbarSettings::Save()
|
||||
{
|
||||
SHSetValueW(hkExplorer, NULL, L"EnableAutotray", REG_DWORD, &bHideInactiveIcons, sizeof(bHideInactiveIcons));
|
||||
SHSetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", REG_DWORD, &bPreferDate, sizeof(bPreferDate));
|
||||
SHSetValueW(hkExplorer, L"Advanced", L"ShowSeconds", REG_DWORD, &bShowSeconds, sizeof(bShowSeconds));
|
||||
SHSetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", REG_DWORD, &bGroupButtons, sizeof(bGroupButtons));
|
||||
BOOL bAllowSizeMove = !bLock;
|
||||
|
@ -44,6 +45,9 @@ BOOL TaskbarSettings::Load()
|
|||
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", NULL, &dwValue, &cbSize);
|
||||
bLock = (dwRet == ERROR_SUCCESS) ? (dwValue == 0) : TRUE;
|
||||
|
||||
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", NULL, &dwValue, &cbSize);
|
||||
bPreferDate = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; /* This is opt-in setting */
|
||||
|
||||
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"ShowSeconds", NULL, &dwValue, &cbSize);
|
||||
bShowSeconds = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
if (VisibleLines == 2)
|
||||
{
|
||||
/* 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++)
|
||||
{
|
||||
if (LineSizes[i].cx != 0)
|
||||
{
|
||||
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 */
|
||||
|
|
|
@ -1894,6 +1894,7 @@ HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\Classi
|
|||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",,0x00000012
|
||||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","ListviewShadow",0x00010003,0x00000001
|
||||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HideFileExt",0x00010003,0x00000000
|
||||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","PreferDateOverWeekday",0x00010003,0x00000001
|
||||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","StartMenuLogoff",0x00010003,0x00000001
|
||||
; "Hidden" to be changed to 2 if we later want to have "Hide hidden files by default"
|
||||
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","Hidden",0x00010003,1
|
||||
|
|
Loading…
Reference in a new issue