Skip to content
Merged
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 @@ -1688,17 +1688,30 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) {
}
case OS.CDDS_PREPAINT: {
long result = OS.CDRF_DODEFAULT;
if (background != -1 || (foreground != -1 && OS.IsWindowEnabled (handle)) || (state & CUSTOM_DRAW_ITEM) != 0) {
if (background != -1 || (foreground != -1 && OS.IsWindowEnabled (handle)) || (state & CUSTOM_DRAW_ITEM) != 0 || display.useDarkModeExplorerTheme) {
result = OS.CDRF_NOTIFYITEMDRAW;
}
return new LRESULT (result);
}
case OS.CDDS_ITEMPREPAINT: {
long result = OS.TBCDRF_USECDCOLORS;
nmcd.clrBtnFace = getBackgroundPixel (child);
int bgPixel = getBackgroundPixel (child);
nmcd.clrBtnFace = bgPixel;
nmcd.clrBtnHighlight = getDifferentColor (bgPixel);
nmcd.clrText = getForegroundPixel (child);
OS.MoveMemory (lParam, nmcd, NMTBCUSTOMDRAW.sizeof);
Comment on lines 1697 to 1702
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Because CDDS_PREPAINT now opts into item custom-draw whenever display.useDarkModeExplorerTheme is enabled, CDDS_ITEMPREPAINT will run even when the app hasn't set custom colors. Returning TBCDRF_USECDCOLORS and always setting nmcd.clrText via getForegroundPixel(child) can override the native dark-theme text color (similar to how Button.customForegroundDrawing() only changes text color when an explicit foreground is set). Consider only setting clrText (and/or returning TBCDRF_USECDCOLORS) when ToolBar/ToolItem has an explicit foreground/background override; for the dark-mode-only path you can just paint the hot/checked background and return TBCDRF_NOBACKGROUND to keep native text rendering.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the TBCDRF_USECDCOLORS + clrText pattern is pre-existing and out of scope for this fix

if (child != null && child.background != -1) {
if (display.useDarkModeExplorerTheme && (nmcd.uItemState & (OS.CDIS_CHECKED | OS.CDIS_HOT)) != 0) {
int pixel;
if ((nmcd.uItemState & OS.CDIS_CHECKED) != 0) {
pixel = getDifferentColor (bgPixel);
} else {
pixel = getSlightlyDifferentColor (bgPixel);
}
RECT rect = new RECT (nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
OS.SetDCBrushColor (nmcd.hdc, pixel);
OS.FillRect (nmcd.hdc, rect, OS.GetStockObject (OS.DC_BRUSH));
result |= OS.TBCDRF_NOBACKGROUND;
} else if (child != null && child.background != -1) {
RECT rect = new RECT (nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
OS.SetDCBrushColor (nmcd.hdc, child.background);
OS.FillRect (nmcd.hdc, rect, OS.GetStockObject (OS.DC_BRUSH));
Expand Down
Loading