Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,27 @@ protected override void OnPaint(PaintEventArgs e)
}
else
{
GroupBoxRenderer.DrawGroupBox(
if (FindForm() is Form form && form.ForeColor != SystemColors.ControlText)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. The fix uses FindForm() which jumps directly to the top-level Form. If the GroupBox is inside a Panel or UserControl that has a custom ForeColor, the ambient color from that intermediate parent is ignored.

    WinForms ambient property inheritance walks the full parent chain. this.ForeColor already returns the correct inherited value from any ancestor. A simpler and more correct fix would be to check whether the inherited ForeColor differs from the default

  2. form.ForeColor != SystemColors.ControlText assumes the default form ForeColor is always SystemColors.ControlText. If a high-contrast theme or custom Windows theme changes the default, this comparison could produce incorrect results

{
GroupBoxRenderer.DrawGroupBox(
e,
new Rectangle(0, 0, Width, Height),
Text,
Font,
form.ForeColor,
textFlags,
gbState);
}
else
{
GroupBoxRenderer.DrawGroupBox(
e,
new Rectangle(0, 0, Width, Height),
Text,
Font,
textFlags,
gbState);
}
Comment on lines +443 to +463

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lines 457-462 (the inner else) have inconsistent indentation — the DrawGroupBox call arguments are not indented relative to the method call, unlike the rest of the file

}
}

Expand Down
Loading