1616namespace {
1717
1818// Use private Windows API to set window theme.
19- HRESULT TrySetWindowTheme (HWND hWnd, bool dark) {
19+ BOOL CALLBACK TrySetWindowTheme (HWND hWnd, LPARAM lparam) {
20+ bool dark = static_cast <bool >(lparam);
2021 HRESULT result =
2122 SetWindowTheme (hWnd, dark ? DARK_MODE_STRING_NAME : L" " , nullptr );
2223 if (FAILED (result))
23- return result ;
24+ return FALSE ;
2425
2526 const BOOL isDarkMode = dark;
2627 if (FAILED (DwmSetWindowAttribute (hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE ,
@@ -29,7 +30,7 @@ HRESULT TrySetWindowTheme(HWND hWnd, bool dark) {
2930 DwmSetWindowAttribute (hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 ,
3031 &isDarkMode, sizeof (isDarkMode));
3132 if (FAILED (result))
32- return result ;
33+ return FALSE ;
3334 }
3435
3536 // Toggle the nonclient area active state to force a redraw
@@ -50,7 +51,10 @@ void SetDarkModeForWindow(HWND hWnd) {
5051 ui::NativeTheme* theme = ui::NativeTheme::GetInstanceForNativeUi ();
5152 bool dark =
5253 theme->ShouldUseDarkColors () && !theme->UserHasContrastPreference ();
53- TrySetWindowTheme (hWnd, dark);
54+
55+ // Set theme for all windows (e.g. DevTools)
56+ EnumThreadWindows (GetCurrentThreadId (), TrySetWindowTheme,
57+ static_cast <LPARAM >(dark));
5458}
5559
5660} // namespace win
0 commit comments