Skip to content

Commit 98ec7f7

Browse files
author
Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box)
committed
Fixes #11933
`ToolStripRenderer.OnRenderItemCheck` only inverted the check mark glyph when `SystemInformation.HighContrast` was true. In regular dark mode the check mark icons (designed for light backgrounds) were drawn as-is, resulting in a dark glyph on a dark background. Extended the inversion logic in `ToolStripRenderer.OnRenderItemCheck` to also trigger when `Application.IsDarkModeEnabled` is true, using the existing `ControlPaint.CreateBitmapWithInvertedForeColor` helper. The high contrast path is preserved as a separate branch since it already handles its own background-color detection. Indeterminate and checked `ToolStripMenuItem` icons are now clearly visible in dark mode on `ContextMenuStrip`, `MenuStrip`, `StatusStrip` and `ToolStrip` drop-down buttons. No Minimal Manual - 11.0.100-preview.1.26078.121
1 parent c7ffcb5 commit 98ec7f7

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripRenderer.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,22 @@ protected virtual void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
863863
image = CreateDisabledImage(image, e.ImageAttributes);
864864
}
865865

866-
if (SystemInformation.HighContrast && image is Bitmap bitmap)
866+
if (image is Bitmap bitmap)
867867
{
868-
Color backgroundColor = e.Item.Selected ? SystemColors.Highlight : e.Item.BackColor;
869-
870-
if (ControlPaint.IsDark(backgroundColor))
868+
if (Application.IsDarkModeEnabled)
869+
{
870+
// In dark mode, the check mark icons are dark glyphs designed for light
871+
// backgrounds. Invert the foreground color so they are visible on dark backgrounds.
872+
image = ControlPaint.CreateBitmapWithInvertedForeColor(bitmap, e.Item.BackColor);
873+
}
874+
else if (SystemInformation.HighContrast)
871875
{
872-
Image invertedImage = ControlPaint.CreateBitmapWithInvertedForeColor(bitmap, e.Item.BackColor);
873-
image = invertedImage;
876+
Color backgroundColor = e.Item.Selected ? SystemColors.Highlight : e.Item.BackColor;
877+
878+
if (ControlPaint.IsDark(backgroundColor))
879+
{
880+
image = ControlPaint.CreateBitmapWithInvertedForeColor(bitmap, e.Item.BackColor);
881+
}
874882
}
875883
}
876884
}

0 commit comments

Comments
 (0)