Skip to content

Fix issue 11954: [Dark Mode] ToolTip is not in dark mode after enabled SystemColorMode.Dark#14381

Open
SimonZhao888 wants to merge 3 commits intodotnet:mainfrom
SimonZhao888:Fix_issue_11954
Open

Fix issue 11954: [Dark Mode] ToolTip is not in dark mode after enabled SystemColorMode.Dark#14381
SimonZhao888 wants to merge 3 commits intodotnet:mainfrom
SimonZhao888:Fix_issue_11954

Conversation

@SimonZhao888
Copy link
Member

@SimonZhao888 SimonZhao888 commented Mar 11, 2026

Fixes #11954

Proposed changes

  • Add dark mode support to Tooltip

Customer Impact

  • ToolTip is in dark mode after enabled SystemColorMode.Dark

Regression?

  • Yes

Risk

  • Min

Screenshots

Before

image

After

image

Test methodology

  • Manual

Test environment(s)

  • 11.0.0-alpha.1.25619.109
Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.31573%. Comparing base (e98325a) to head (4c05296).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
Debug 77.31573% <0.00000%> (+0.00324%) ⬆️
integration 19.13377% <0.00000%> (+0.00356%) ⬆️
production 52.28498% <0.00000%> (+0.00762%) ⬆️
test 97.41916% <ø> (ø)
unit 49.63699% <0.00000%> (+0.00452%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When CreateHandle is executed, activeForm is null.

Image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-DarkMode Issues relating to Dark Mode feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dark Mode] ToolTip is not in dark mode after enabled SystemColorMode.Dark

3 participants