Reactos

[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

authored by

Carl J. Bialorucki and committed by
GitHub
19c8574e ebb7c052

+42 -11
+1
base/shell/explorer/precomp.h
··· 208 208 BOOL bLock; 209 209 BOOL bGroupButtons; 210 210 BOOL bShowSeconds; 211 + BOOL bPreferDate; 211 212 BOOL bHideInactiveIcons; 212 213 TW_STRUCKRECTS2 sr; 213 214
+4
base/shell/explorer/settings.cpp
··· 25 25 BOOL TaskbarSettings::Save() 26 26 { 27 27 SHSetValueW(hkExplorer, NULL, L"EnableAutotray", REG_DWORD, &bHideInactiveIcons, sizeof(bHideInactiveIcons)); 28 + SHSetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", REG_DWORD, &bPreferDate, sizeof(bPreferDate)); 28 29 SHSetValueW(hkExplorer, L"Advanced", L"ShowSeconds", REG_DWORD, &bShowSeconds, sizeof(bShowSeconds)); 29 30 SHSetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", REG_DWORD, &bGroupButtons, sizeof(bGroupButtons)); 30 31 BOOL bAllowSizeMove = !bLock; ··· 43 44 cbSize = sizeof(dwValue); 44 45 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", NULL, &dwValue, &cbSize); 45 46 bLock = (dwRet == ERROR_SUCCESS) ? (dwValue == 0) : TRUE; 47 + 48 + dwRet = SHGetValueW(hkExplorer, L"Advanced", L"PreferDateOverWeekday", NULL, &dwValue, &cbSize); 49 + bPreferDate = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; /* This is opt-in setting */ 46 50 47 51 dwRet = SHGetValueW(hkExplorer, L"Advanced", L"ShowSeconds", NULL, &dwValue, &cbSize); 48 52 bShowSeconds = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;
+36 -11
base/shell/explorer/trayclock.cpp
··· 38 38 const UINT ClockWndFormatsCount = _ARRAYSIZE(ClockWndFormats); 39 39 40 40 #define CLOCKWND_FORMAT_COUNT ClockWndFormatsCount 41 + #define CLOCKWND_FORMAT_TIME 0 42 + #define CLOCKWND_FORMAT_DAY 1 43 + #define CLOCKWND_FORMAT_DATE 2 41 44 42 45 static const WCHAR szTrayClockWndClass[] = L"TrayClockWClass"; 43 46 ··· 98 101 LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 99 102 LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 100 103 LRESULT OnLButtonDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 104 + VOID PaintLine(IN HDC hDC, IN OUT RECT *rcClient, IN UINT LineNumber, IN UINT szLinesIndex); 101 105 102 106 public: 103 107 ··· 529 533 rcClient.top = (rcClient.bottom - CurrentSize.cy) / 2; 530 534 rcClient.bottom = rcClient.top + CurrentSize.cy; 531 535 532 - for (i = 0, line = 0; 533 - i < CLOCKWND_FORMAT_COUNT && line < VisibleLines; 534 - i++) 536 + if (VisibleLines == 2) 537 + { 538 + /* Display either time and weekday (by default), or time and date (opt-in) */ 539 + PaintLine(hDC, &rcClient, 0, CLOCKWND_FORMAT_TIME); 540 + PaintLine(hDC, &rcClient, 1, 541 + g_TaskbarSettings.bPreferDate ? CLOCKWND_FORMAT_DATE : CLOCKWND_FORMAT_DAY); 542 + } 543 + else 535 544 { 536 - if (LineSizes[i].cx != 0) 545 + for (i = 0, line = 0; 546 + i < CLOCKWND_FORMAT_COUNT && line < VisibleLines; 547 + i++) 537 548 { 538 - TextOut(hDC, 539 - (rcClient.right - LineSizes[i].cx) / 2, 540 - rcClient.top + TRAY_CLOCK_WND_SPACING_Y, 541 - szLines[i], 542 - wcslen(szLines[i])); 543 - 544 - rcClient.top += LineSizes[i].cy + LineSpacing; 549 + PaintLine(hDC, &rcClient, i, i); 545 550 line++; 546 551 } 547 552 } ··· 555 560 EndPaint(&ps); 556 561 557 562 return TRUE; 563 + } 564 + 565 + VOID CTrayClockWnd::PaintLine(IN HDC hDC, IN OUT RECT *rcClient, IN UINT LineNumber, IN UINT szLinesIndex) 566 + { 567 + if (LineSizes[LineNumber].cx == 0) 568 + return; 569 + 570 + TextOut(hDC, 571 + (rcClient->right - LineSizes[szLinesIndex].cx) / 2, 572 + rcClient->top + TRAY_CLOCK_WND_SPACING_Y, 573 + szLines[szLinesIndex], 574 + wcslen(szLines[szLinesIndex])); 575 + 576 + rcClient->top += LineSizes[LineNumber].cy + LineSpacing; 558 577 } 559 578 560 579 VOID CTrayClockWnd::SetFont(IN HFONT hNewFont, IN BOOL bRedraw) ··· 702 721 { 703 722 ResetTime(); 704 723 } 724 + } 725 + 726 + if (newSettings->bPreferDate != g_TaskbarSettings.bPreferDate) 727 + { 728 + g_TaskbarSettings.bPreferDate = newSettings->bPreferDate; 729 + bRealign = TRUE; 705 730 } 706 731 707 732 if (bRealign)
+1
boot/bootdata/hivedef.inf
··· 1894 1894 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}",,0x00000012 1895 1895 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","ListviewShadow",0x00010003,0x00000001 1896 1896 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HideFileExt",0x00010003,0x00000000 1897 + HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","PreferDateOverWeekday",0x00010003,0x00000001 1897 1898 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","StartMenuLogoff",0x00010003,0x00000001 1898 1899 ; "Hidden" to be changed to 2 if we later want to have "Hide hidden files by default" 1899 1900 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced","Hidden",0x00010003,1