MSW: Fix dark mode border flicker (PR #26646)

13 views
Skip to first unread message

Steve Cornett

unread,
Jun 29, 2026, 10:54:00 PM (2 days ago) Jun 29
to wx-...@googlegroups.com, Subscribed

This is a proposed alternative to #26635. This is starkly minimalistic while retaining the two essential ideas proposed by @memoarfaa.

  1. The flicker problem is solved by using a clipping region when calling MSWDefWindowProc() to prevent drawing the light mode border.

  2. The dark mode border is drawn explicitly instead of using UxTheme so that it looks good on older versions of windows. This is extremely simple for now. The border is always a 1-pixel thick gray rectangle, regardless of border style. The color is hard-coded to what I see with wxBORDER_SIMPLE/WS_BORDER. A possible improvement is to get the color by querying a theme class with TMT_BORDERCOLOR. I experimented with this but was not able to get a satisfactory color. Other possible improvements might be rounded corners or an indication of focus for some controls. For example, in light mode, the edit control shows a blue line at the bottom when focused.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26646

Commit Summary

  • cbd42bc Fix dark mode border flicker
  • fe361dc Explicitly draw dark mode border

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26646@github.com>

Steve Cornett

unread,
Jun 30, 2026, 1:32:45 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Push

@stevecor pushed 1 commit.


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26646/before/fe361dc8674e1f760dd33f86cbc4f5f4d118b5fe/after/aa54d2ae6fc53571930c22ad18aec6e5e3cc535c@github.com>

VZ

unread,
Jun 30, 2026, 4:42:26 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed

@vadz approved this pull request.

Thanks, I really like how simple this is, so I'm going to merge it and while we should improve it later, this should be an improvement right now.


In src/msw/window.cpp:

> -
-                    // The part and state values match for the themes we use.
-                    static_assert((int)EP_EDITTEXT == (int)LVP_LISTITEM, "parts differ?");
-                    static_assert((int)EP_EDITTEXT == (int)BP_PUSHBUTTON, "parts differ?");
-                    static_assert((int)ETS_NORMAL == (int)LISS_NORMAL, "states differ?");
-                    static_assert((int)ETS_NORMAL == (int)PBS_NORMAL, "states differ?");
-
-                    // Make sure the background is in a proper state
-                    if (::IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
+                    if ( wxMSWDarkMode::IsActive() )
+                    {
+                        // There does not seem to be a theme class that draws a good
+                        // border on all supported versions of Windows. Manually draw a
+                        // 1-pixel thick border. Use the observed colour of the simple
+                        // border, WS_BORDER.
+                        AutoHBRUSH brushBorder(0x646464);

A bit strange that it's not any of the colours returned by wxDarkModeSettings::GetColour(). Maybe we should map wxSYS_COLOUR_INACTIVEBORDER to it, for example?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26646/review/4603941640@github.com>

VZ

unread,
Jun 30, 2026, 4:44:14 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26646)

Just FYI: I'm applying this as 2 commits in order not to have the "typo fix" as a separate commit. And thanks for the commits message bodies!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26646/c4847755979@github.com>

VZ

unread,
Jun 30, 2026, 7:31:21 PM (2 days ago) Jun 30
to wx-...@googlegroups.com, Subscribed

Closed #26646 via 0401dd5.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26646/issue_event/27402847965@github.com>

Reply all
Reply to author
Forward
0 new messages