IonicWind Software

IWBasic => GUI Central => Topic started by: Bruce Peaslee on September 24, 2010, 04:36:45 PM

Title: Checkbox Color
Post by: Bruce Peaslee on September 24, 2010, 04:36:45 PM
Hi,

How do I change the color of a checkbox control in a dialog?

As the user tabs through the dialog, I want the color to change as the control gets the focus, then back as it moves on.

Thanks,

Bruce
Title: Re: Checkbox Color
Post by: billhsln on September 24, 2010, 04:49:51 PM
This is how my program does it:

UINT BLACK, RED, GREEN, BLUE, YELLOW, CYAN, PINK, GREY, MAGENTA
UINT LBLUE, LYELLOW, WHITE, PURPLE, GOLD, SILVER, BROWN

GOLD    = RGB(255,215,0)
YELLOW  = RGB(255,255,0)
LYELLOW = RGB(255,255,125)
GREEN   = RGB(0,255,0)
BLUE    = RGB(0,0,255)
RED     = RGB(255,0,0)
CYAN    = RGB(0,255,255)
PINK    = RGB(255,192,203)
GREY    = RGB(125,125,125)
LBLUE   = RGB(0,125,255)
MAGENTA = RGB(255,0,255)
PURPLE  = RGB(128,0,128)
BROWN   = RGB(165,42,42)
SILVER  = RGB(105,105,105)
WHITE   = RGB(255,255,255)
BLACK   = RGB(0,0,0)

' Set color of Check Boxes
SETCONTROLCOLOR d1,D1_CB1, PINK, PURPLE
SETCONTROLCOLOR d1,D1_CB2, CYAN, BLUE

Hope that helps.

Bill
Title: Re: Checkbox Color
Post by: LarryMc on September 24, 2010, 05:01:25 PM
If you are just wanting to change the fore/background colors of the overall area the box and text occupy then what Bill said with the SETCONTROLCOLOR command is correct.

If you are wanting to change the color of the little box itself I think you will have to subclass it and do your on WM_PAINT handler.
Or create custom "button" with the BS_OWNERDRAWN flag and draw everything yourself in the custom buttons handler.

LarryMc
Title: Re: Checkbox Color
Post by: Bruce Peaslee on September 24, 2010, 05:19:07 PM
I just wanted to change the color as the user tabs through them.

I checked Bill's example and it works. However, the checkboxes weren't sending the  @BN_SETFOCUS and @BN_KILLFOCUS messages until I added BS_NOTIFY style to the control.


Case  LOT_CHK_VACANT
Case& LOT_CHK_FORSALE
Case& LOT_CHK_RENTED
    If @NOTIFYCODE = BN_SETFOCUS
        SetControlColor dlgLotData, @CONTROLID, BLACK, RED
    EndIf
    If @NOTIFYCODE = BN_KILLFOCUS
        SetControlColor dlgLotData, @CONTROLID, BLACK, RGB(175, 175, 175)
    EndIf
Title: Re: Checkbox Color
Post by: LarryMc on September 24, 2010, 05:23:48 PM
I've been bit by forgrtting the BS_NOTIFY flag before.

Just my personal preference:

Case  LOT_CHK_VACANT
Case& LOT_CHK_FORSALE
Case& LOT_CHK_RENTED
    SELECT @NOTIFYCODE
       case BN_SETFOCUS
          SetControlColor dlgLotData, @CONTROLID, BLACK, RED
       case  BN_KILLFOCUS
          SetControlColor dlgLotData, @CONTROLID, BLACK, RGB(175, 175, 175)
   ENDSELECT


LarryMc
Title: Re: Checkbox Color
Post by: Bruce Peaslee on September 24, 2010, 05:26:33 PM
Yeah, they call them "bytes" for a reason.

Thanks to both of you.