This is easily solved by providing a Windows handle to any brush you want to use to paint the button background. You do this every time you receive the WM_CTLCOLORBTN message in the message handler of the parent window of the button.
I mocked a small demo application that compares two different buttons side by side. Both are standard Win32 BUTTON controls, but one on the left handles the WM_CTLCOLORBTN message and indicates a brush with the same color as the background of the window. You can immediately see the difference - light gray (or, more precisely, the default color for three-dimensional controls, COLOR_3DFACE ) bordering the button’s rectangle has disappeared and the button looks much better than the custom background color:

The effect also works in Windows XP with visual themes turned on - a screenshot of the same application:

And the code I used to create the above effect is almost ridiculously simple. Add this to the application main window procedure ( MainWndProc ) as described above. You do not need to touch the buttons.
HBRUSH hButtonBackColor = NULL; LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CTLCOLORBTN: { if (!hButtonBackColor) {
However, make sure that the specified brush is the same color as the background color of your window - a transparent brush may not work correctly. Similarly, for a pattern brush (does anyone use them more?), The name of the brush should be set according to the background.
Always make sure that you open any brushes you created by calling DeleteObject !! In C ++, you do this by making the CBrush object (or equivalent) a member of your dialog class so that it is automatically destroyed. In C, you need to process the WM_NCDESTROY message and manually remove the brush.
Also note that you do not need to specify BS_OWNERDRAW style to make this trick work. The above example uses two standard button controls created using only the following window style flags: WS_CHILD , WS_VISIBLE and BS_PUSHBUTTON .
Of course, if your design is more complex than the example above (for example, your buttons overlap several backgrounds), you will most likely have to go along the owner’s route. I just think that an unnecessary task for a task is as simple as the one you seem to be describing.