Fix ComboBox dark mode theme on first TabPage#14578
Open
SimonZhao888 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a dark-mode regression where ComboBox controls placed on the first TabPage of a TabControl lost their specialized dark theming. TabControl.ApplyDarkModeOnDemand calls EnumChildWindows, which enumerates all descendant windows (not just direct children). The previous StyleChildren callback unconditionally applied DarkMode_Explorer to every descendant, overwriting the DarkMode_CFD theme that ComboBox.OnHandleCreated had set on itself. The fix scopes the theme application to direct children (i.e. TabPages) by comparing PInvoke.GetParent(handle) against the TabControl's HWND.
Changes:
- Guard
StyleChildrensoSetWindowTheme(DarkMode_Explorer)is only applied when the enumerated handle's native parent is the TabControl itself. - Return
truefor non-direct descendants so enumeration continues, leaving control-specific dark themes (e.g. ComboBox) intact.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14107
Proposed changes
TabControl.StyleChildren()to only apply dark mode theme to direct children (TabPages), not descendant controlsPInvoke.GetParent()to identify direct childrenSetWindowTheme()for proper error handlingCustomer Impact
Application.SetColorMode(SystemColorMode.Dark)with TabControl containing ComboBox controlsRegression?
Risk
Screenshots
Before
After
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow