@@ -251,7 +251,7 @@ COLORREF DarkMode::setEdgeColor(COLORREF clrNew) { return getTheme().
251251COLORREF DarkMode::setHotEdgeColor (COLORREF clrNew) { return getTheme ().setColorHotEdge (clrNew); }
252252COLORREF DarkMode::setDisabledEdgeColor (COLORREF clrNew) { return getTheme ().setColorDisabledEdge (clrNew); }
253253
254- void DarkMode::setThemeColors (Colors* colors)
254+ void DarkMode::setThemeColors (const Colors* colors)
255255{
256256 if (colors != nullptr )
257257 {
@@ -301,7 +301,7 @@ COLORREF DarkMode::setHeaderHotBackgroundColor(COLORREF clrNew) { return getThem
301301COLORREF DarkMode::setHeaderTextColor (COLORREF clrNew) { return getThemeView ().setColorHeaderText (clrNew); }
302302COLORREF DarkMode::setHeaderEdgeColor (COLORREF clrNew) { return getThemeView ().setColorHeaderEdge (clrNew); }
303303
304- void DarkMode::setViewColors (ColorsView* colors)
304+ void DarkMode::setViewColors (const ColorsView* colors)
305305{
306306 if (colors != nullptr )
307307 {
@@ -1202,7 +1202,7 @@ static void setTabCtrlPaintSubclass(HWND hWnd)
12021202 * @see dmlib_subclass::TabPaintSubclass()
12031203 * @see setTabCtrlPaintSubclass()
12041204 */
1205- static void removeTabCtrlPaintSubclass (HWND hWnd)
1205+ static void removeTabCtrlPaintSubclass (HWND hWnd) noexcept
12061206{
12071207 dmlib_subclass::RemoveSubclass<dmlib_subclass::TabData>(hWnd, dmlib_subclass::TabPaintSubclass, dmlib_subclass::SubclassID::tabPaint);
12081208}
@@ -2516,39 +2516,11 @@ void DarkMode::enableSysLinkCtrlCtlColor(HWND hWnd)
25162516 */
25172517void DarkMode::setDarkTitleBarEx (HWND hWnd, bool useWin11Features)
25182518{
2519- static constexpr DWORD win10Build2004 = 19041 ;
2520- static constexpr DWORD win11Mica = 22621 ;
2521- if (DarkMode::getWindowsBuildNumber () >= win10Build2004)
2519+ if (static constexpr DWORD win10Build2004 = 19041 ;
2520+ DarkMode::getWindowsBuildNumber () >= win10Build2004)
25222521 {
25232522 const BOOL useDark = DarkMode::isExperimentalActive () ? TRUE : FALSE ;
25242523 ::DwmSetWindowAttribute (hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &useDark, sizeof (useDark));
2525-
2526- if (useWin11Features && DarkMode::isAtLeastWindows11 ())
2527- {
2528- ::DwmSetWindowAttribute (hWnd, DWMWA_WINDOW_CORNER_PREFERENCE, &g_dmCfg.m_roundCorner, sizeof (g_dmCfg.m_roundCorner));
2529- ::DwmSetWindowAttribute (hWnd, DWMWA_BORDER_COLOR, &g_dmCfg.m_borderColor, sizeof (g_dmCfg.m_borderColor));
2530-
2531- bool canColorizeTitleBar = true ;
2532-
2533- if (DarkMode::getWindowsBuildNumber () >= win11Mica)
2534- {
2535- if (g_dmCfg.m_micaExtend && g_dmCfg.m_mica != DWMSBT_AUTO && !DarkMode::isWindowsModeEnabled () && (g_dmCfg.m_dmType == DarkModeType::dark))
2536- {
2537- static constexpr MARGINS margins{ -1 , 0 , 0 , 0 };
2538- ::DwmExtendFrameIntoClientArea (hWnd, &margins);
2539- }
2540-
2541- ::DwmSetWindowAttribute (hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &g_dmCfg.m_mica, sizeof (g_dmCfg.m_mica));
2542-
2543- canColorizeTitleBar = !g_dmCfg.m_micaExtend ;
2544- }
2545-
2546- canColorizeTitleBar = g_dmCfg.m_colorizeTitleBar && canColorizeTitleBar && DarkMode::isEnabled ();
2547- const COLORREF clrDlg = canColorizeTitleBar ? DarkMode::getDlgBackgroundColor () : DWMWA_COLOR_DEFAULT;
2548- const COLORREF clrText = canColorizeTitleBar ? DarkMode::getTextColor () : DWMWA_COLOR_DEFAULT;
2549- ::DwmSetWindowAttribute (hWnd, DWMWA_CAPTION_COLOR, &clrDlg, sizeof (clrDlg));
2550- ::DwmSetWindowAttribute (hWnd, DWMWA_TEXT_COLOR, &clrText, sizeof (clrText));
2551- }
25522524 }
25532525#if defined(_DARKMODELIB_ALLOW_OLD_OS) && (_DARKMODELIB_ALLOW_OLD_OS > 0)
25542526 else
@@ -2557,13 +2529,50 @@ void DarkMode::setDarkTitleBarEx(HWND hWnd, bool useWin11Features)
25572529 dmlib_win32api::RefreshTitleBarThemeColor (hWnd);
25582530 }
25592531#endif
2532+
2533+ if (!DarkMode::isAtLeastWindows11 ())
2534+ {
25602535 // on Windows 10 title bar needs refresh when changing colors
2561- if (DarkMode::isAtLeastWindows10 () && !DarkMode::isAtLeastWindows11 ())
2536+ if (DarkMode::isAtLeastWindows10 ())
2537+ {
2538+ const bool isActive = (hWnd == ::GetActiveWindow ()) && (hWnd == ::GetForegroundWindow ());
2539+ ::SendMessage (hWnd, WM_NCACTIVATE, static_cast <WPARAM>(!isActive), 0);
2540+ ::SendMessage (hWnd, WM_NCACTIVATE, static_cast <WPARAM>(isActive), 0);
2541+ }
2542+ return ;
2543+ }
2544+
2545+ if (!useWin11Features)
25622546 {
2563- const bool isActive = (hWnd == ::GetActiveWindow ()) && (hWnd == ::GetForegroundWindow ());
2564- ::SendMessage (hWnd, WM_NCACTIVATE, static_cast <WPARAM>(!isActive), 0);
2565- ::SendMessage (hWnd, WM_NCACTIVATE, static_cast <WPARAM>(isActive), 0);
2547+ return ;
25662548 }
2549+
2550+ ::DwmSetWindowAttribute (hWnd, DWMWA_WINDOW_CORNER_PREFERENCE, &g_dmCfg.m_roundCorner, sizeof (g_dmCfg.m_roundCorner));
2551+ ::DwmSetWindowAttribute (hWnd, DWMWA_BORDER_COLOR, &g_dmCfg.m_borderColor, sizeof (g_dmCfg.m_borderColor));
2552+
2553+ bool canColorizeTitleBar = true ;
2554+
2555+ if (static constexpr DWORD win11Mica = 22621 ;
2556+ DarkMode::getWindowsBuildNumber () >= win11Mica)
2557+ {
2558+ if (g_dmCfg.m_micaExtend && g_dmCfg.m_mica != DWMSBT_AUTO
2559+ && !DarkMode::isWindowsModeEnabled ()
2560+ && (g_dmCfg.m_dmType == DarkModeType::dark))
2561+ {
2562+ static constexpr MARGINS margins{ -1 , 0 , 0 , 0 };
2563+ ::DwmExtendFrameIntoClientArea (hWnd, &margins);
2564+ }
2565+
2566+ ::DwmSetWindowAttribute (hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &g_dmCfg.m_mica, sizeof (g_dmCfg.m_mica));
2567+
2568+ canColorizeTitleBar = !g_dmCfg.m_micaExtend ;
2569+ }
2570+
2571+ canColorizeTitleBar = g_dmCfg.m_colorizeTitleBar && canColorizeTitleBar && DarkMode::isEnabled ();
2572+ const COLORREF clrDlg = canColorizeTitleBar ? DarkMode::getDlgBackgroundColor () : DWMWA_COLOR_DEFAULT;
2573+ const COLORREF clrText = canColorizeTitleBar ? DarkMode::getTextColor () : DWMWA_COLOR_DEFAULT;
2574+ ::DwmSetWindowAttribute (hWnd, DWMWA_CAPTION_COLOR, &clrDlg, sizeof (clrDlg));
2575+ ::DwmSetWindowAttribute (hWnd, DWMWA_TEXT_COLOR, &clrText, sizeof (clrText));
25672576}
25682577
25692578/* *
0 commit comments