Fix dark titlebar for Windows 10 20H1

This commit is contained in:
Charles Milette 2019-12-21 15:32:01 -05:00
parent 7ba3a297a5
commit 44051b7064
No known key found for this signature in database
GPG key ID: 1A5AE81377AD973A
2 changed files with 9 additions and 9 deletions

View file

@ -2084,7 +2084,9 @@ public enum DwmWindowAttribute : uint
/// </summary>
DWMWA_LAST,
// Undocumented, available since October 2018 update (build 17763)
DWMWA_USE_IMMERSIVE_DARK_MODE = 19
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19,
// Windows 10 20H1 changed the value of the constant
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
}
public enum InputType : int

View file

@ -235,16 +235,14 @@ public static bool UseImmersiveDarkMode(IntPtr handle, bool enabled)
{
if (Helpers.IsWindows10OrGreater(17763))
{
try
var attribute = DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
if (Helpers.IsWindows10OrGreater(18985))
{
int useImmersiveDarkMode = enabled ? 1 : 0;
int result = DwmSetWindowAttribute(handle, (int)DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref useImmersiveDarkMode, sizeof(int));
return result == 0;
}
catch (Exception e)
{
DebugHelper.WriteException(e);
attribute = DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE;
}
int useImmersiveDarkMode = enabled ? 1 : 0;
return DwmSetWindowAttribute(handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
}
return false;