wxMSW opaque background on buttons (Issue #26312)

27 views
Skip to first unread message

Ryan Ogurek

unread,
Mar 21, 2026, 12:16:11 PMMar 21
to wx-...@googlegroups.com, Subscribed
ryancog created an issue (wxWidgets/wxWidgets#26312)

Description

On wxMSW, there's a rectangular border drawn behind buttons. This is not very noticeable on Windows 10 (but it is there), but it is very much so on Windows 11.

It is drawn the same color as the default background, so it is not usually visible, however.

In my app (I don't remember why anymore...), I set the background color on my frames using the system settings, and the color it returns is not actually the default for the frame background (it's a bit lighter, at least on dark mode), so it's noticeable in my app, and any other frame which uses a non-default background.

Expected vs observed behaviour:

I'm not sure why this opaque background is drawn, but I wouldn't expect it to be there.

It's also odd to me that the button does not fill the entire size of its window. You can see in my screenshots the rectangle drawn is the same size as a wxChoice, but the button itself is not. (It's a single pixel smaller on all sides). I'm not sure if that's a Win32 quirk or something wx is doing, but it feels related enough to this to mention.

Patch or snippet allowing to reproduce the problem:

I've got a little sample here that I've reproduced the issue with:

/*
 * wxWidgets Win32 wxButton Sample
 */

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/choice.h>

class Sample : public wxApp {
public:
    bool OnInit() override {
        MSWEnableDarkMode();
        
        auto *frame{new wxFrame(nullptr, wxID_ANY, "Sample")};
        auto *panel{new wxPanel(frame)};

        auto *sizer{new wxBoxSizer(wxHORIZONTAL)};

        auto *button{new wxButton(panel, wxID_ANY, "A Button")};

        auto *choice{new wxChoice(panel, wxID_ANY)};
        choice->Set(std::vector{"Something", "SomethingElse"});

        sizer->AddStretchSpacer();
        sizer->Add(button, 0, wxALIGN_CENTER);
        sizer->AddSpacer(8);
        sizer->Add(choice, 0, wxALIGN_CENTER);
        sizer->AddStretchSpacer();

        panel->SetSizer(sizer);

        frame->SetBackgroundColour(
            wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK)
        );
        frame->SetMinSize({300, 200});
        frame->Show();

        return true;
    }
};

wxIMPLEMENT_APP(Sample);

To Reproduce:

  1. Ensure Windows apps are set to dark mode
  2. Run the sample application
  3. Observe the outline on the button

On Windows 10:

image.png (view on web)

On Windows 11 (Please disregard the other button here... I was playing with something else):

image.png (view on web)

Platform and version information

  • wxWidgets version you use: 3.3.0
  • wxWidgets port you use: wxMSW
  • OS and its version: Windows 10 & 11


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

Dan

unread,
Apr 5, 2026, 7:32:40 PM (4 days ago) Apr 5
to wx-...@googlegroups.com, Subscribed
CEXT-Dan left a comment (wxWidgets/wxWidgets#26312)

Hi, have you tied overriding wxDarkModeSettings to change the background color?

It could be that explicitly setting colors confuses how control backgrounds are painted. I’ve been playing around with custom theming and it seems to be a good starting point.

wx3.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/26312/4189722633@github.com>

Ryan Ogurek

unread,
Apr 5, 2026, 8:56:21 PM (4 days ago) Apr 5
to wx-...@googlegroups.com, Subscribed

Closed #26312 as completed.


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/issue/26312/issue_event/24211848709@github.com>

Ryan Ogurek

unread,
Apr 5, 2026, 8:56:22 PM (4 days ago) Apr 5
to wx-...@googlegroups.com, Subscribed
ryancog left a comment (wxWidgets/wxWidgets#26312)

Hey @CEXT-Dan,

No, I have not! I am not very well versed in Windows, or wxWidgets on Windows, so while I was aware of the dark mode enable function, I didn’t realize you could customize it this way.

If the control background is drawn in accordance with that theming, then that seems perfectly fine, and it’s just my knowledge that’s lacking :)

I realized I set the background manually was because I failed to put a wxPanel into the frame, and so was confused when the grey default was drawn. This would’ve been when I was very first being introduced to wx
Reply all
Reply to author
Forward
0 new messages