MSW: Dark mode for common dialogs (PR #26780)

41 views
Skip to first unread message

Steve Cornett

unread,
Aug 4, 2026, 3:01:28 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Subscribed

This PR introduces an architecture for adding dark mode support to the common dialogs, wxColourDialog, wxFindReplaceDialog, wxFontDialog, wxPageSetupDialog, wxPrintDialog. The initial implementation is for only the two simplest dialogs, wxColourDialog and wxFindReplaceDialog.

A new function wxMSWDarkMode::DialogHookProc() encapsulates the implementation. This function can be called from an existing dialog hook procedure, or can be set as the dialog hook procedure if there is none already. This hook handles dialog messages to enable dark mode on the dialog window and children. For configuring the children, there are two basic methods. If the theme DarkMode_DarkTheme is available, that is used and the appearance is quite good. For older Windows versions, the various classes of controls need special handling. There is currently special handling for Button and Edit controls. More complicated controls such as ComboBox will need to be subclassed and owner-drawn, but that is not implemented yet.

See #26599.


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

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

Commit Summary

  • 3944afd Dark mode for common dialogs

File Changes

(4 files)

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/26780@github.com>

Steve Cornett

unread,
Aug 4, 2026, 3:26:57 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Push

@stevecor pushed 1 commit.

  • 1ff3f85 Fix use of deprecated macro


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/26780/before/3944afd827866a690175b0fc20f74a5526cc6e5b/after/1ff3f850e30840ee6b0b6986d968b85ba3eccd83@github.com>

Steve Cornett

unread,
Aug 4, 2026, 4:06:44 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Subscribed
stevecor left a comment (wxWidgets/wxWidgets#26780)

The appearance of wxColourDialog:

Image: image (view on web)

The appearance of wxFindReplaceDialog with and without DarkMode_DarkTheme below:

Image: image (view on web)


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/26780/c5184022484@github.com>

VZ

unread,
Aug 4, 2026, 6:37:16 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks, it's rather amazing that the results are so good with only relatively few changes.

Do you understand why wxButton looks fine in dark mode (with the appropriate theme) while the buttons in the dialogs do not? It's also a bit weird to use a different workaround for the buttons here and in src/msw/taskdlg.cpp but I guess we can live with it as long as it's simple enough.


In src/msw/darkmode.cpp:

> +    }
+    return true;
+}
+
+UINT_PTR CALLBACK DialogHookProc(HWND hwnd, UINT uiMsg, WPARAM wParam,
+    LPARAM WXUNUSED(lParam))
+{
+    if ( !IsActive() )
+        return 0;
+
+    // Window background brush. There is only one handle instance which is
+    // adequate if there is only one common dialog shown at a time. In the
+    // unlikely event more than one is shown at a time, the only problem is
+    // some dark/light drawing inconsistencies, which is an acceptable
+    // trade-off for the simplicity of managing this handle locally.
+    static HBRUSH s_bgBrush = nullptr;

Why not use wxTheBrushList? Chances are this brush is already used elsewhere anyhow in dark mode and like this we don't need to bother with not leaking it.


In src/msw/darkmode.cpp:

> +    // adequate if there is only one common dialog shown at a time. In the
+    // unlikely event more than one is shown at a time, the only problem is
+    // some dark/light drawing inconsistencies, which is an acceptable
+    // trade-off for the simplicity of managing this handle locally.
+    static HBRUSH s_bgBrush = nullptr;
+
+    switch ( uiMsg )
+    {
+        case WM_INITDIALOG:
+            // Enable dark for dialog window.
+            wxMSWDarkMode::ConfigureTLW(hwnd);
+            s_bgBrush = CreateSolidBrush(
+                wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE).GetPixel());
+
+            // Enable dark mode for children.
+            EnumChildWindows(hwnd, EnableDialogChild, 0);

This is very minor but we usually use :: to show that we're calling global Win32 functions, not wx ones, i.e.

⬇️ Suggested change
-            EnumChildWindows(hwnd, EnableDialogChild, 0);
+            ::EnumChildWindows(hwnd, EnableDialogChild, 0);


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/26780/review/4859498951@github.com>

Steve Cornett

unread,
Aug 4, 2026, 6:52:42 PM (5 days ago) Aug 4
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/26780/before/1ff3f850e30840ee6b0b6986d968b85ba3eccd83/after/a64bd708323f9f9c85dab1d1eb764d794632feb9@github.com>

Steve Cornett

unread,
Aug 4, 2026, 6:59:10 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Subscribed
stevecor left a comment (wxWidgets/wxWidgets#26780)

Do you understand why wxButton looks fine in dark mode (with the appropriate theme) while the buttons in the dialogs do not?

I used the wrong background color (wxSYS_COLOUR_BTNFACE instead of wxSYS_COLOUR_WINDOW).

It's also a bit weird to use a different workaround for the buttons here and in src/msw/taskdlg.cpp but I guess we can live with it as long as it's simple enough.

I cannot understand the code in taskdlg.cpp. I search through it on "button" but I cannot follow how it works.


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/26780/c5185534994@github.com>

Steve Cornett

unread,
Aug 4, 2026, 7:04:13 PM (5 days ago) Aug 4
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/26780/before/a64bd708323f9f9c85dab1d1eb764d794632feb9/after/3809a649f81a77c1919e46028a153c3fb310e484@github.com>

VZ

unread,
Aug 4, 2026, 7:07:10 PM (5 days ago) Aug 4
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26780)

I cannot understand the code in taskdlg.cpp. I search through it on "button" but I cannot follow how it works.

AFAIR it just does it pixel-by-pixel in TDPaintPixelSwap(). It's not the most elegant approach, but it works (under Windows 10).

OTOH an even better question might be how does it work there under Windows 11, with its native dark theme: could we perhaps apply DarkMode_DarkTheme::TaskDialog to the other dialogs too?


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/26780/c5185588705@github.com>

PB

unread,
Aug 5, 2026, 9:44:30 AM (5 days ago) Aug 5
to wx-...@googlegroups.com, Subscribed

@PBfordev commented on this pull request.


In src/msw/darkmode.cpp:

> +    switch ( uiMsg )
+    {
+        case WM_INITDIALOG:
+            // Enable dark for dialog window.
+            wxMSWDarkMode::ConfigureTLW(hwnd);
+            // Enable dark mode for children.
+            ::EnumChildWindows(hwnd, EnableDialogChild, 0);
+            break;
+
+        case WM_CTLCOLORBTN:
+        case WM_CTLCOLORDLG:
+            return (INT_PTR)GetBackgroundBrush();
+
+        case WM_CTLCOLOREDIT:
+        case WM_CTLCOLORSTATIC:
+            SetBkColor((HDC)wParam,

Nitpick as usual

⬇️ Suggested change
-            SetBkColor((HDC)wParam,
+            ::SetBkColor((HDC)wParam,

You use the global scope resolution operator for Win32 API everywhere else except here and SetTextColor() and GetBackgroundBrush() below.


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/26780/review/4865021382@github.com>

Steve Cornett

unread,
Aug 5, 2026, 5:25:36 PM (4 days ago) Aug 5
to wx-...@googlegroups.com, Push

@stevecor pushed 2 commits.

  • ab3fac8 Fix check box color on old Windows
  • 6fd3e36 Add dark mode support for wxFontDialog and wxPageSetupDialog


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/26780/before/3809a649f81a77c1919e46028a153c3fb310e484/after/6fd3e3650075094d740985e90b77927d52e0b2c6@github.com>

Steve Cornett

unread,
Aug 5, 2026, 5:36:28 PM (4 days ago) Aug 5
to wx-...@googlegroups.com, Subscribed
stevecor left a comment (wxWidgets/wxWidgets#26780)

Here is how the dialogs look on current Windows 11 (left) and old Windows 10 (right). For older Windows versions, check box tick marks are still light mode. I don't have any good idea how to handle that. In wxFontDialog, the Sample is not a control, and therefore I did not try to fix that. I did not address the wxPrintDialog class. The wxPrinter class already supports dark mode.

Image: image (view on web) Image: image (view on web) Image: image (view on web) Image: image (view on web)


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/26780/c5197654641@github.com>

Steve Cornett

unread,
Aug 7, 2026, 6:31:06 PM (2 days ago) Aug 7
to wx-...@googlegroups.com, Push

@stevecor pushed 1 commit.

  • 25291ee Add dark mode check box drawing


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/26780/before/6fd3e3650075094d740985e90b77927d52e0b2c6/after/25291ee484d4772c7d2ee210a4a7bc7e806a7bca@github.com>

Steve Cornett

unread,
Aug 7, 2026, 8:22:23 PM (2 days ago) Aug 7
to wx-...@googlegroups.com, Subscribed
stevecor left a comment (wxWidgets/wxWidgets#26780)

Check boxes are implemented for old Windows versions.


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/26780/c5223490207@github.com>

Reply all
Reply to author
Forward
0 new messages