https://git.reactos.org/?p=reactos.git;a=commitdiff;h=19c8574ec834acc8bc082fbe0dd62de73b22202e

commit 19c8574ec834acc8bc082fbe0dd62de73b22202e
Author:     Carl J. Bialorucki <[email protected]>
AuthorDate: Sat Jul 8 16:04:45 2023 -0600
Commit:     GitHub <[email protected]>
CommitDate: Sun Jul 9 01:04:45 2023 +0300

    [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
---
 base/shell/explorer/precomp.h     |  1 +
 base/shell/explorer/settings.cpp  |  4 ++++
 base/shell/explorer/trayclock.cpp | 47 ++++++++++++++++++++++++++++++---------
 boot/bootdata/hivedef.inf         |  1 +
 4 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/base/shell/explorer/precomp.h b/base/shell/explorer/precomp.h
index 881c2d05bce..7f58465ad8e 100644
--- a/base/shell/explorer/precomp.h
+++ b/base/shell/explorer/precomp.h
@@ -208,6 +208,7 @@ struct TaskbarSettings
     BOOL bLock;
     BOOL bGroupButtons;
     BOOL bShowSeconds;
+    BOOL bPreferDate;
     BOOL bHideInactiveIcons;
     TW_STRUCKRECTS2 sr;
 
diff --git a/base/shell/explorer/settings.cpp b/base/shell/explorer/settings.cpp
index c47993d1d7a..9e6051eb9d7 100644
--- a/base/shell/explorer/settings.cpp
+++ b/base/shell/explorer/settings.cpp
@@ -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;
 
diff --git a/base/shell/explorer/trayclock.cpp 
b/base/shell/explorer/trayclock.cpp
index 8aaddca02a8..39277e19a04 100644
--- a/base/shell/explorer/trayclock.cpp
+++ b/base/shell/explorer/trayclock.cpp
@@ -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 */
diff --git a/boot/bootdata/hivedef.inf b/boot/bootdata/hivedef.inf
index bbf27e93139..6774bbc2a0b 100644
--- a/boot/bootdata/hivedef.inf
+++ b/boot/bootdata/hivedef.inf
@@ -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

Reply via email to