Button background
-
I am creating buttons dynamically in my dialog box by creating them as windows using CreateWindow and putting bitmaps on top of the buttons. This works fine, however, I want to change the background colour of these buttons to a lighter colour. I'm guessing that I use SendMessage but as to which message and parameters I'm lost. Could anybody point me in the right direction. I've checked some articles but they are geared more to using the resource editor or owner-drawn buttons. Thanks in advance for any help, Nick
-
I am creating buttons dynamically in my dialog box by creating them as windows using CreateWindow and putting bitmaps on top of the buttons. This works fine, however, I want to change the background colour of these buttons to a lighter colour. I'm guessing that I use SendMessage but as to which message and parameters I'm lost. Could anybody point me in the right direction. I've checked some articles but they are geared more to using the resource editor or owner-drawn buttons. Thanks in advance for any help, Nick
Sorry - you can't change the background of the button with one simple SendMessage. And processing WM_CTLCOLORBTN won't help either; here's what MSDN says: 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. So, if you need custom background, you have to use owner-draw. Tomasz Sowinski -- http://www.shooltz.com
-
Sorry - you can't change the background of the button with one simple SendMessage. And processing WM_CTLCOLORBTN won't help either; here's what MSDN says: 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. So, if you need custom background, you have to use owner-draw. Tomasz Sowinski -- http://www.shooltz.com
Ok, thanks, I suppose I can get around it by altering the bitmap itself to have a white border or something, I'll work on that. The reason I wanted to do it was because some of the bitmaps I was drawing had a grey edge on some sides which was the same colour as the button itself so the border wasn't showing. Thanks anyway, Nick