Skip to content

Fix ProgressBar dark mode rendering inconsistency across style variants#14551

Open
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_14546_ProgressBar_broken_appearance_in_DarkMode
Open

Fix ProgressBar dark mode rendering inconsistency across style variants#14551
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_14546_ProgressBar_broken_appearance_in_DarkMode

Conversation

@LeafShi1
Copy link
Copy Markdown
Member

@LeafShi1 LeafShi1 commented May 21, 2026

Fixes #14546

Root Cause

The native themed ProgressBar rendering on newer Windows builds applies style-dependent visual effects in dark mode. As a result, Blocks, Continuous, and Marquee do not share a single consistent rendering path. When the control depends on native theming, the background and foreground colors can diverge across styles.

Proposed changes

  • Disable native ProgressBar theming in dark mode and drive ProgressBar colors through explicit color messages.
  • Reapply theming and colors after handle recreation, style changes, color changes, and user-preference updates.
  • Use SystemColors.ControlText as the dark-mode background color to satisfy contrast requirements.
  • Preserve system-controlled ProgressBar colors in the classic/native rendering path.
  • Apply explicit ProgressBar colors only in the dark-mode workaround path used to ensure consistent rendering across style variants.

Customer Impact

  • Fixes inconsistent ProgressBar appearance in dark mode and improves readability and contrast between the progress fill and background.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

Blocks, Continuous, and Marquee render with different visual results.

Recording.2026-05-20.095837.mp4

After

Three ProgressBar styles (Blocks, Continuous, Marquee) render with consistent colors in dark mode and color changes and style switching work correctly

AfterChanges.mp4

Test methodology

  • Manually

Test environment(s)

  • .net 11.0.0-preview.5.26268.112
Microsoft Reviewers: Open in CodeFlow

@LeafShi1 LeafShi1 requested a review from a team as a code owner May 21, 2026 06:15
@github-actions github-actions Bot added the area-DarkMode Issues relating to Dark Mode feature label May 21, 2026
@SimonZhao888 SimonZhao888 requested a review from Copilot May 22, 2026 02:01
@SimonZhao888
Copy link
Copy Markdown
Member

Looks good to me!

Copy link
Copy Markdown
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

This PR updates WinForms ProgressBar dark-mode behavior to avoid Windows 11 (25H2+) style-dependent themed rendering differences by disabling native theming in the affected cases and explicitly driving bar/background colors via PBM color messages, reapplying this on handle recreation and relevant system/user changes.

Changes:

  • Centralizes dark-mode/custom-color handling in ApplyTheming() and calls it from handle creation, style changes, color changes, and user preference updates.
  • Introduces “effective” back/fore color helpers to ensure consistent default colors (including a dark-mode default background).
  • Removes the prior OnCreateControl-time dark-mode workaround in favor of handle-based reapplication.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// across Blocks/Continuous/Marquee. Disable visual styles and drive colors via PBM_SET*COLOR
// for consistent appearance.
PInvoke.SetWindowTheme(HWND, " ", " ");
}
Comment on lines +117 to +118
// Re-apply theming after handle recreation
ApplyTheming();
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] ProgressBar broken appearance when changing ProgressBarStyle at runtime on Windows 11 25H2

3 participants