Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darken TabControl in dark mode #12471

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public unsafe partial class Control :
internal const string ExplorerThemeIdentifier = "Explorer";
internal const string ItemsViewThemeIdentifier = "ItemsView";
internal const string ComboBoxButtonThemeIdentifier = "CFD";
internal const string BannerContainerThemeIdentifier = "FileExplorerBannerContainer";

private const short PaintLayerBackground = 1;
private const short PaintLayerForeground = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,14 @@ protected override void OnHandleCreated(EventArgs e)
}

UpdateTabSelection(false);

#pragma warning disable WFO5001
if (Application.IsDarkModeEnabled)
{
PInvoke.SetWindowTheme(HWND, null, $"{DarkModeIdentifier}::{BannerContainerThemeIdentifier}");
PInvokeCore.EnumChildWindows(this, StyleChildren);
}
#pragma warning restore WFO5001
}

protected override void OnHandleDestroyed(EventArgs e)
Expand Down Expand Up @@ -1771,6 +1779,10 @@ private bool ShouldSerializeItemSize()
return !_padding.Equals(s_defaultPaddingPoint);
}

private BOOL StyleChildren(HWND handle) =>
PInvoke.SetWindowTheme(handle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null)
.Succeeded;

/// <summary>
/// Returns a string representation for this control.
/// </summary>
Expand Down