When I use the style constant "BS_PUSHLIKE" with a radiobutton or a checkbox to force the display to act like an old car radio push button I can no longer assign colors with the SETCONTROLCOLOR.
Seems like I should still be able to change the colors from the default button colors.Code snippet:
CONST BS_PUSHLIKE = 0x1000
CONTROL m_wpanel,@RADIOBUTTON,"Test2",470,125,40,16,0,9
SETCONTROLCOLOR m_wpanel,9,RGB(255,0,0),RGB(130,205,144):'green
'results in red on light green text of radiobutton
CONTROL m_wpanel,@RADIOBUTTON,"Test2",470,125,40,16,BS_PUSHLIKE,9
SETCONTROLCOLOR m_wpanel,9,RGB(255,0,0),RGB(130,205,144):'green
'results in black on grey text of displayed button
Get same exact result if I change radiobutton to checkbox
Larry
Nope. It's a Windows limitation. From MSDN:
Quote
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.
In other words if you want different colors on a BS_PUSHLIKE button you have to roll your own drawing routine and handle all the different state imagery. I've written the code for Emergence to handle manually drawing buttons (BS_PUSHBUTTON, BS_DEFPUSHBUTTON) so colors can be applied, and you can use the same technique for owner drawing the BS_PUSHLIKE check boxes and radio buttons. In the Emergence library source file control.eba the function 'DrawButton' does the work of creating colored buttons.
If you just want a different color, and don't plan on changing the colors during the run of the program, then you could use bitmaps for the up/down states.
Paul.
Thanks Paul,
It seems like by now I would know enough to know if there appears to be a flaw that whatever is causing it is a Uncle Bill problem and not a Paul problem. ;)
Larry
Quote..If you just want a different color, and don't plan on changing the colors during the run of the program, then you could use bitmaps for the up/down states.
I tried a @RADIOBUTTON control with the BS_PUSHLIKE|@CTLBTNBITMAP flags and it wouldn't take my bitmap but the text did go away on the button.
If I used @BUTTON control with @CTLBTNBITMAP flag then my bitmap did work as expected.
Not a big thing; I'm just experimenting.
Larry
Sorry, Not as simple as that ;). You have to use an ownerdraw control and draw the bitmaps in the supplied rectangle according to the state of the control.
Paul.
Oh, I misunderstood.
Thanks
Larry