Page 1 of 1
Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 1:17 am
by Piotr D
Hi,
is a way to change color of check box in DCCHECKBOX (and in DCRADIOBUTTON)? For example, I want that check box will be yellow when is edit protect, and white (normal) when no. I know, that when use clause WHEN the check box can be grayed, but this is for me not useful.
Regards
Piotr
Re: Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 1:37 am
by Tom
Hi, Piotr.
Just add a COLOR-codeblock:
Code: Select all
@ 1,1 DCCHECKBOX lWhatever PROMPT 'Check this' COLOR {||{GRA_CLR_WHITE,GRA_CLR_RED}} // same with DCRADIO
This will color the text and the background of the checkbox and/or radio button, not the controls themselves.
Re: Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 2:20 am
by Piotr D
Tom,
the COLOR work fine, but only for caption (text). I want change color only for the check box (inside).
Piotr
Re: Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 6:37 am
by Tom
This is something you can't do when working with standard Xbase parts. You will have to use a different control.
Re: Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 10:24 am
by rdonnay
You could simulate this by creating a set of bitmaps with different colors.
They would need to look like a checkbox.
Re: Color of DCCHECKBOX
Posted: Mon Mar 30, 2020 11:46 pm
by Auge_Ohr
Piotr D wrote:the COLOR work fine, but only for caption (text). I want change color only for the check box (inside).
not sure which Part you mean with "inside"
- Checkbox_Color.jpg (23.13 KiB) Viewed 17658 times
"Check" in Checkbox itself on left side is a Bitmap and depend on visual Style
Frame with Text are Font-Color where Font-Color itself canĀ“t be change
"green" is what i have try "to paint" ... but it is not stable this Way.
what you need is Ownerdraw ... it is "just" a Button.
---
Roger talk about seperat Image to show Status.
as i know Express++ have "PUSHLIKE" Style for Button
- DXE_PushLike.jpg (7.82 KiB) Viewed 17658 times
this is also possible with Checkbox, Radio and 3-State Button.
Re: Color of DCCHECKBOX
Posted: Tue Mar 31, 2020 5:21 am
by Piotr D
Jimmy,
"inside" I understand stricte. I mean about pool inside small frame, a background for check, which is ever white.
Piotr
Re: Color of DCCHECKBOX
Posted: Tue Mar 31, 2020 5:38 am
by rdonnay
Piotr -
Now that I am locked down in my apartment I have few activities that preserve my interests, therefore this little challenge sounds like something that is welcomed. I will write you a sample program.
Re: Color of DCCHECKBOX
Posted: Tue Mar 31, 2020 8:24 am
by rdonnay
Here is the sample program that I promised (no bitmaps required) :
Code: Select all
#INCLUDE "dcdialog.CH"
#INCLUDE "dcbitmap.CH"
#INCLUDE "appevent.CH"
#command @ <row>, <col> CHECKBUTTON <checked> CAPTION <caption>;
=> CheckButton( GetList, <row>, <col>, @<checked>, <caption> )
FUNCTION Main()
LOCAL GetList[0], lCheck1 := .f., lCheck2 := .f., lCheck3 := .t.
@0,0 DCSAY 'Check Buttons:' SAYSIZE 0 FONT '10.Arial'
@2,0 CHECKBUTTON lCheck1 CAPTION 'Check me First'
@4,0 CHECKBUTTON lCheck2 CAPTION 'Check me Next'
@6,0 CHECKBUTTON lCheck3 CAPTION 'Check me Last'
DCREAD GUI FIT TITLE 'Check Button Test'
RETURN nil
* ---------
FUNCTION CheckButton( GetList, nRow, nCol, lChecked, cCaption )
LOCAL oButton
@ nRow, nCol DCPUSHBUTTONXP ;
CAPTION {|| IIF(lChecked,'4',' ')} ;
SIZE 5,1.8 ;
ACTION {|a,b,o|lChecked := !lChecked, ;
o:setCaption(IIF(lChecked,'4',' ')), ;
o:bgColor := IIF(lChecked,GRA_CLR_YELLOW,GRA_CLR_WHITE ), ;
o:invalidateRect() } ;
OBJECT oButton ;
FONT '26.ZapFDingBats' ;
GRADIENT 1 REVERSE ;
COLOR nil, IIF(lChecked,GRA_CLR_YELLOW,GRA_CLR_WHITE) ;
CLICKCOLOR nil, GRA_CLR_WHITE ;
BORDERCOLOR GRA_CLR_BLACK ;
RADIUS 10 ;
FOCUSRECT 0
@ DCGUI_ROW, DCGUI_COL + 10 DCSAY cCaption SAYSIZE 0 ;
FONT '16.Arial' ;
EVAL {|o|o:lbClick := {||Eval(oButton:activate)}}
RETURN nil
* ---------
PROC appsys ; RETURN
Re: Color of DCCHECKBOX
Posted: Tue Mar 31, 2020 10:26 am
by Piotr D
Roger,
Thank you for that tips. This is probably the only right way to achieve the effect I expect. You are (as always) great. I wish you good health.
Regards
Piotr