Fix issue 11954: [Dark Mode] ToolTip is not in dark mode after enabled SystemColorMode.Dark#14381
Fix issue 11954: [Dark Mode] ToolTip is not in dark mode after enabled SystemColorMode.Dark#14381SimonZhao888 wants to merge 3 commits intodotnet:mainfrom
Conversation
…d SystemColorMode.Dark
There was a problem hiding this comment.
Pull request overview
Adds dark mode theming for WinForms ToolTip windows when Application.SetColorMode(SystemColorMode.Dark) is enabled, aligning tooltip rendering with the rest of the app’s dark mode experience (issue #11954).
Changes:
- Apply a dark-mode window theme to the tooltip HWND during handle creation when dark mode is enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/System.Windows.Forms/System/Windows/Forms/ToolTip/ToolTip.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/System/Windows/Forms/ToolTip/ToolTip.cs
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14381 +/- ##
===================================================
+ Coverage 77.31249% 77.31573% +0.00324%
===================================================
Files 3265 3265
Lines 644447 644451 +4
Branches 47631 47632 +1
===================================================
+ Hits 498238 498262 +24
+ Misses 142512 142499 -13
+ Partials 3697 3690 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| PInvokeCore.SendMessage(this, PInvoke.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); | ||
|
|
||
| Form? activeForm = Form.ActiveForm; | ||
| if (Application.IsDarkModeEnabled && !SystemInformation.HighContrast && activeForm is not null && activeForm.DarkModeRequestState is true) |
There was a problem hiding this comment.
Determining the DarkModeRequestState of the host control is necessary, but during the CreateHandle phase of ToolTip, the host control's handle may not have been created yet, or the TopLevelControl may not have been determined. Therefore, setting the WindowTheme during WmShow or WmPop might be a more appropriate time.

Fixes #11954
Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
After
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow