I am not using a dialog, I'm using my own custom class which I have registered and then used the CreateWindow
call to create it, I have preset the background color to red when registering:
WNDCLASSEX wc; wc.hbrBackground = CreateSolidBrush(RGB(255, 0, 0));
But now I want to change the background color at runtime, by e.g. clicking a button to change it to blue.
I have tried to use SetBkColor()
call in the WM_PAINT
, and tried returning a brush from the WM_CTLCOLORDLG
message, they don't work.
Any help?
Select Start > Settings > Personalization > Colors, and then choose your own color, or let Windows pull an accent color from your background.
Select Start > Settings . Select Personalization > Colors. Under Choose your color, select Light. To manually select an accent color, choose one under Recent colors or Windows colors, or select Custom color for an even more detailed option.
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
From Window Background comes:
...The system paints the background for a window or gives the window the opportunity to do so by sending it a WM_ERASEBKGND message when the application calls BeginPaint. If an application does not process the message but passes it to DefWindowProc, the system erases the background by filling it with the pattern in the background brush specified by the window's class.....
...... An application can process the WM_ERASEBKGND message even though a class background brush is defined. This is typical in applications that enable the user to change the window background color or pattern for a specified window without affecting other windows in the class. In such cases, the application must not pass the message to DefWindowProc. .....
So, use the WM_ERASEBKGND message's wParam to get the DC and paint the background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With