Color of DCCHECKBOX

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Piotr D
Posts: 131
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Color of DCCHECKBOX

#1 Post 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

User avatar
Tom
Posts: 1205
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Color of DCCHECKBOX

#2 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Piotr D
Posts: 131
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Color of DCCHECKBOX

#3 Post by Piotr D »

Tom,
the COLOR work fine, but only for caption (text). I want change color only for the check box (inside).

Piotr

User avatar
Tom
Posts: 1205
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Color of DCCHECKBOX

#4 Post by Tom »

This is something you can't do when working with standard Xbase parts. You will have to use a different control.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Color of DCCHECKBOX

#5 Post by rdonnay »

You could simulate this by creating a set of bitmaps with different colors.

They would need to look like a checkbox.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Color of DCCHECKBOX

#6 Post 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
Checkbox_Color.jpg (23.13 KiB) Viewed 17652 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
DXE_PushLike.jpg (7.82 KiB) Viewed 17652 times
this is also possible with Checkbox, Radio and 3-State Button.
greetings by OHR
Jimmy

Piotr D
Posts: 131
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Color of DCCHECKBOX

#7 Post by Piotr D »

Jimmy,
"inside" I understand stricte. I mean about pool inside small frame, a background for check, which is ever white.

Piotr

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Color of DCCHECKBOX

#8 Post 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.
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Color of DCCHECKBOX

#9 Post 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
Attachments
CheckButton.jpg
CheckButton.jpg (20.83 KiB) Viewed 17634 times
The eXpress train is coming - and it has more cars.

Piotr D
Posts: 131
Joined: Mon Jul 28, 2014 1:26 am
Location: Poznań, Poland

Re: Color of DCCHECKBOX

#10 Post 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

Post Reply