Skip to content

Commit 35d31af

Browse files
willibrandonKlausLoeffelmann
authored andcommitted
Darken TabControl in dark mode
1 parent 9bf0496 commit 35d31af

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/System.Windows.Forms/System/Windows/Forms/Control.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public unsafe partial class Control :
162162
internal const string ExplorerThemeIdentifier = "Explorer";
163163
internal const string ItemsViewThemeIdentifier = "ItemsView";
164164
internal const string ComboBoxButtonThemeIdentifier = "CFD";
165+
internal const string BannerContainerThemeIdentifier = "FileExplorerBannerContainer";
165166

166167
private const short PaintLayerBackground = 1;
167168
private const short PaintLayerForeground = 2;

src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabControl.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,14 @@ protected override void OnHandleCreated(EventArgs e)
12891289
}
12901290

12911291
UpdateTabSelection(false);
1292+
1293+
#pragma warning disable WFO5001
1294+
if (Application.IsDarkModeEnabled)
1295+
{
1296+
PInvoke.SetWindowTheme(HWND, null, $"{DarkModeIdentifier}::{BannerContainerThemeIdentifier}");
1297+
PInvokeCore.EnumChildWindows(this, StyleUpDown);
1298+
}
1299+
#pragma warning restore WFO5001
12921300
}
12931301

12941302
protected override void OnHandleDestroyed(EventArgs e)
@@ -1771,6 +1779,9 @@ private bool ShouldSerializeItemSize()
17711779
return !_padding.Equals(s_defaultPaddingPoint);
17721780
}
17731781

1782+
private BOOL StyleUpDown(HWND handle)
1783+
=> PInvoke.SetWindowTheme(handle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null).Succeeded;
1784+
17741785
/// <summary>
17751786
/// Returns a string representation for this control.
17761787
/// </summary>

0 commit comments

Comments
 (0)