From e7ad10241f12bb3760d6cdb73fd7077f87ce1cd3 Mon Sep 17 00:00:00 2001 From: Brock Mammen Date: Sat, 23 Mar 2019 11:16:44 -0500 Subject: [PATCH] [EXPLORER] Add date tooltip to taskbar clock CORE-11444 --- base/shell/explorer/trayclock.cpp | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/base/shell/explorer/trayclock.cpp b/base/shell/explorer/trayclock.cpp index b4e85d951c3..c49f154554c 100644 --- a/base/shell/explorer/trayclock.cpp +++ b/base/shell/explorer/trayclock.cpp @@ -51,6 +51,7 @@ class CTrayClockWnd : COLORREF textColor; RECT rcText; SYSTEMTIME LocalTime; + CTooltips m_tooltip; union { @@ -388,6 +389,31 @@ VOID CTrayClockWnd::UpdateWnd() GetParent().SendMessage(WM_NOTIFY, 0, (LPARAM) &nmh); } } + + int iDateLength = GetDateFormat(LOCALE_USER_DEFAULT, + DATE_LONGDATE, + &LocalTime, + NULL, + NULL, + 0); + if (iDateLength <= 0) + { + return; + } + + WCHAR* szDate = new WCHAR[iDateLength]; + if (GetDateFormat(LOCALE_USER_DEFAULT, + DATE_LONGDATE, + &LocalTime, + NULL, + szDate, + iDateLength) > 0) + { + m_tooltip.UpdateTipText(m_hWnd, + reinterpret_cast(m_hWnd), + szDate); + } + delete[] szDate; } VOID CTrayClockWnd::Update() @@ -624,7 +650,8 @@ LRESULT CTrayClockWnd::OnGetMinimumSize(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT CTrayClockWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - return HTTRANSPARENT; + // HTCLIENT is returned to receive WM_MOUSEMOVE messages for the tooltip + return HTCLIENT; } LRESULT CTrayClockWnd::OnSetFont(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) @@ -635,6 +662,18 @@ LRESULT CTrayClockWnd::OnSetFont(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& LRESULT CTrayClockWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + m_tooltip.Create(m_hWnd, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP); + + TOOLINFOW ti = { 0 }; + ti.cbSize = TTTOOLINFOW_V1_SIZE; + ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + ti.hwnd = m_hWnd; + ti.uId = reinterpret_cast(m_hWnd); + ti.lpszText = NULL; + ti.lParam = NULL; + + m_tooltip.AddTool(&ti); + ResetTime(); return TRUE; } -- 2.17.1