diff --git a/Dotnet/Cef/CefService.cs b/Dotnet/Cef/CefService.cs index 2093503e..8ea38f21 100644 --- a/Dotnet/Cef/CefService.cs +++ b/Dotnet/Cef/CefService.cs @@ -37,7 +37,7 @@ namespace VRCX PersistSessionCookies = true, UserAgent = Program.Version, BrowserSubprocessPath = Environment.ProcessPath, - BackgroundColor = 0xFF101010 + BackgroundColor = 0xFF0A0A0A }; cefSettings.RegisterScheme(new CefCustomScheme diff --git a/Dotnet/Cef/WinformThemer.cs b/Dotnet/Cef/WinformThemer.cs index 9aa65fa3..16490c5d 100644 --- a/Dotnet/Cef/WinformThemer.cs +++ b/Dotnet/Cef/WinformThemer.cs @@ -78,19 +78,30 @@ namespace VRCX //Set the theme of the window SetThemeToGlobal(form.Handle); - //Change opacity to foce full redraw + //Change opacity to force full redraw form.Opacity = 0.99999; form.Opacity = 1; } })); } + private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; + private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20; + private const int DWMWA_CAPTION_COLOR = 35; + private static void SetThemeToGlobal(IntPtr handle) { + int whiteColor = 0xFFFFFF; + int blackColor = 0x000000; if (GetTheme(handle) != currentTheme) { - if (PInvoke.DwmSetWindowAttribute(handle, 19, new[] { currentTheme }, 4) != 0) - PInvoke.DwmSetWindowAttribute(handle, 20, new[] { currentTheme }, 4); + if (PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ref currentTheme, sizeof(int)) != 0) + PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref currentTheme, sizeof(int)); + + if (currentTheme == 1) + PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref blackColor, sizeof(int)); + else + PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref whiteColor, sizeof(int)); } } @@ -146,7 +157,7 @@ namespace VRCX internal static class PInvoke { [DllImport("DwmApi")] - internal static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, int[] pvAttribute, int cbAttribute); + internal static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute); [DllImport("DwmApi")] internal static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, IntPtr pvAttribute, int cbAttribute);