Closed leeooox closed 3 years ago
Background color of button don't work for visual styles. Reference: https://docs.microsoft.com/en-us/windows/win32/controls/visual-styles-overview
Hi @khchen,
Thanks. But how to disable the visual styles in wNim for the purpose of button background display?
Sorry, it's my mistake. Visual styles is not a problem. According to https://docs.microsoft.com/en-us/windows/win32/controls/wm-ctlcolorbtn:
By default, the DefWindowProc function selects the default system colors for the button. Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight, and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button. For more information, see Creating Owner-Drawn Controls.
wButton is BS_PUSHBUTTON. So the only way to change it's color is by Creating Owner-Drawn Controls
BTW, you can disable visual styles by add -d:nores. However, some controls may not work because I had never tested them.
And I believe some codes only make sense with visual styles.
Hi,
When I try to set the background color of the button in my project, it seems only border color is applied while the area inside border unchanged.
This is a simple code to reproduce the issue. The task is to set the background of button to red color As the picture, the statictext control works well, but button has problem.