does OnCtlColor work for buttons?
-
Howdy, The OnCtlColor function does not seem to do anything for buttons, and scrollbars. MSDN suggests that by processing the CTLCOLOR_BTN case, the background color for all buttons in a dialog can be set. However when I try this nothing happens. The function behaves correctly for other controls, such as edit and static controls. In the OnCtlColor() function I have: if (nCtlColor == CTLCOLOR_BTN) { pDC->SetBkMode(TRANSPARENT); if(m_buttonBrush) hbr = *m_buttonBrush; } and m_buttonBrush is created earlier. Is it possible to use this function.. I would really like to avoid making my own custom button control and subclassing from it. thanks, Tom
-
Howdy, The OnCtlColor function does not seem to do anything for buttons, and scrollbars. MSDN suggests that by processing the CTLCOLOR_BTN case, the background color for all buttons in a dialog can be set. However when I try this nothing happens. The function behaves correctly for other controls, such as edit and static controls. In the OnCtlColor() function I have: if (nCtlColor == CTLCOLOR_BTN) { pDC->SetBkMode(TRANSPARENT); if(m_buttonBrush) hbr = *m_buttonBrush; } and m_buttonBrush is created earlier. Is it possible to use this function.. I would really like to avoid making my own custom button control and subclassing from it. thanks, Tom
Hi, I can vaguely remember, that I also tried to use OnCtlColor a century ago. As far as I can remember, the only colour I cold change was the text colour of that button. Regards GSte
-
Hi, I can vaguely remember, that I also tried to use OnCtlColor a century ago. As far as I can remember, the only colour I cold change was the text colour of that button. Regards GSte
Same here. I could only control the static text, group boxes, and dialog background colors. I just tried again right now and although I do return a brush handle for CTLCOLOR_BTN (and the trace statements I added confirm that), the buttons are drawn using system colors regardless. I ended up creating a color button class (which I wanted to avoid like you) but turned out to be a good thing because I could then make them a bit fancier (e.g. gradient paint).