2

I’d like to know whether it’s possible to change the background color of a wxButton when the mouse is hovering over it. On Windows, I tried handling the enter/leave window events, but it seems the background color is overridden by the system theme. If I turn the theme off, the color change works, but the button no longer looks good.

Is it possible to change only the background color while keeping the rest of the themed appearance?

I’d prefer to avoid fully custom painting and would rather use a flag, hook into a Windows message, or something similar.

asked Nov 26, 2025 at 17:35
2
  • 1
    The short answer is "no, you can't", sorry - this is because having Windows' Visual Styles applied to your controls/widgets is an all-or-nothing thing. The long answer is "yes, but it's complicated" and will involve reimplementing the Button's painting logic using Windows' Visual Styles API directly. I don't think it's worth it. If you want to customize the colors in some way then you could put the button in a wxStaticBox and give that outer box a custom background color. Commented Nov 26, 2025 at 18:55
  • 1
    ...of course, the reason for using wxWidgets is to have a cross-platform UI - which necessarily means you cannot micromanage your UI or overly customize it to this level. But if you only want to target Windows then I suggest ditching wxWidgets and using WinUI which would allow for this (because WinUI's XAML controls are all full reimplementations of Windows' controls - crazy, I know). Commented Nov 26, 2025 at 18:59

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.