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.
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.
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);
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)—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()