wxListCtrl in Darkmode (Issue #26001)

29 views
Skip to first unread message

Harrie Levels

unread,
Nov 30, 2025, 7:12:19 AM (3 days ago) Nov 30
to wx-...@googlegroups.com, Subscribed
BusyHarry created an issue (wxWidgets/wxWidgets#26001)

Platform and version information

wxWidgets V3.3.1 (and latest), Windows10, VisualStudio 2019, all compiled locally

Description

When adapting my app to dark-mode, I found several problems in the wxListCtrl:

  • if you use SetHeaderAttr(), without explicit SetTextColour(), the headertext is black

    • you can see this when you run the 'samples/listctrl' in dark-mode (use 'set wx_msw_dark_mode=2' before running the sample)
    • select menu->Colour->Custom header attributes -> large blue italic header
    • select it again to disable it -> header text is black and (almost) invisible
    • possible solution for dark-mode: in constructor of 'wxItemAttr', set textcolor to default dark-textcolor
  • moving the mouse over the normal text wil NOT highlight the text (header is ok!)

  • if you use mask 'wxLC_HRULES' in the creation flag, the lines are visible, but disappear when you slowly move the mouse over them. A column-resize will show the lines again

    • enable rulers by 'Ctrl+I' or 'menu/list/Toggle lines'
    • for some reasons, I can't reproduce this now anymore in V3.3.1, but its still doable in V3.3.2 (latest?)
  • looking at the third column, it looks asif the text is clipped at the right side, also overwriting the vertical line (solved in V3.3.2?)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001@github.com>

Maarten

unread,
Nov 30, 2025, 7:44:42 AM (3 days ago) Nov 30
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#26001)

Hi, I think I've fixed drawing the horizontal/vertical rules just yesterday in #25999

To fix the header in dark mode, the dark mode custom header needs to be reinitialized after resetting the custom header. I'll add this to that PR, it seems to fix it for me:

diff --git "a/src/msw/listctrl.cpp" "b/src/msw/listctrl.cpp"
index 5d5c1f7dc83..2c9b6a958a6 100644
--- "a/src/msw/listctrl.cpp"
+++ "b/src/msw/listctrl.cpp"
@@ -707,6 +707,8 @@ bool wxListCtrl::SetHeaderAttr(const wxItemAttr& attr)
 
         delete m_headerCustomDraw;
         m_headerCustomDraw = nullptr;
+
+        MSWInitHeader();
     }
     else // We do have custom attributes.
     {

There have been multiple dark mode listctrl improvements in the last months, so it is likely that the text clipping is resolved in v3.3.2/master.

In dark mode, the whole list is custom draw. Drawing the hover/CDIS_HOT state is currently not done.
I don't think ListView_GetNextItem allows the request this state, so this probably needs to check if the mouse is over an item or not. And then update the uItemState in HandleItemPaint, and then use a different colour in HandleSubItemPrepaint if this state is set? I'll try to look into it further.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3592520142@github.com>

Harrie Levels

unread,
Nov 30, 2025, 8:16:59 AM (3 days ago) Nov 30
to wx-...@googlegroups.com, Subscribed
BusyHarry left a comment (wxWidgets/wxWidgets#26001)

Yes, your change above fixes the headertext in dark mode.
Thank you.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3592543254@github.com>

Harrie Levels

unread,
Nov 30, 2025, 11:50:27 AM (3 days ago) Nov 30
to wx-...@googlegroups.com, Subscribed
BusyHarry left a comment (wxWidgets/wxWidgets#26001)

Wow, that was quick!
Your last commit solved all of the problems.
2 small remarks:

  • when moving the mouse from row zero to the header, the first row is still highlighted.
  • in dark mode, the text in column 3 seems to be one character to the right compared to 'normal' mode: the '2' is below the closing ')' in the header in normal mode, but one position further in dark mode


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3592825215@github.com>

Maarten

unread,
Nov 30, 2025, 3:17:27 PM (3 days ago) Nov 30
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#26001)

Thanks for testing.
I tuned the padding parameters a bit, but I can't get it perfect. In these screenshot you can see light and dark mode blended together, for left aligned and right aligned columns after my changes (at 150% dpi, in case this matters and someone wants to reproduce):

Screenshot.2025-11-30.210747.png (view on web) Screenshot.2025-11-30.210443.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3593279555@github.com>

Harrie Levels

unread,
Dec 1, 2025, 4:36:14 AM (2 days ago) Dec 1
to wx-...@googlegroups.com, Subscribed
BusyHarry left a comment (wxWidgets/wxWidgets#26001)

Your last changes resolve both my remarks.
Thank you for your quick response!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3595517084@github.com>

Maarten

unread,
Dec 2, 2025, 6:11:27 PM (9 hours ago) Dec 2
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#26001)

Hmm, I can't reproduce this. For me it is red (except when hovering over it or selecting it). The red background colour is set via the background attribute in (last line):
https://github.com/wxWidgets/wxWidgets/blob/41a7420f2d7b5de9dc9db978445f04337c7cc619/src/msw/listctrl.cpp#L3404-L3408

Is it correct in master and does my PR break it?

Maybe nmcd.uItemState can have a different state and it is not 0. And I should only check if the selected/hot flags are set. I'll update the PR with this.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26001/3604328721@github.com>

Reply all
Reply to author
Forward
0 new messages