Page 1 of 1

change color checkboxex on line

Posted: Tue Nov 12, 2024 12:39 pm
by Silvio.Falconi
I need to change the color of Prompt if it is checked I made ( but not work)

Code: Select all | Expand

 
@ nRow, ncol CHECKBOX aChk[1]   PROMPT aRuote[1]  SIZE 85, 20 PIXEL  of oDlg COLOR CLR_BLACK, CLR_WHITE   ;
   ON CHANGE ( lBa := !lBa,IIF(aChk[1]:lChecked(), aChk[1]:SetColor( CLR_WHITE, CLR_BLUE ),;
                               aChk[1]:SetColor( CLR_BLACK, CLR_WHITE )),aChk[1]:refresh()) UPDATE
 

any solution ?

Re: change color checkboxex on line

Posted: Tue Nov 12, 2024 9:57 pm
by Detlef
Hi Silvio,

here a strange eample:

Code: Select all | Expand

#include "fivewin.ch"


Function main()
   local oWnd
   local lChk := .f., oChk

   DEFINE WINDOW  oWnd

      @ 5, 12 CHECKBOX oChk VAR lChk;
         PROMPT "hi there";
         SIZE 85, 20 PIXEL;
         OF oWnd COLOR CLR_BLACK, CLR_WHITE ;
         ON CHANGE colorize( oChk, oWnd )

   ACTIVATE WINDOW oWnd

return nil

Function colorize( o, w )

   if eval( o:bSetGet )
      o:nClrText := CLR_WHITE
      o:nClrPane := CLR_BLUE
   else
      o:nClrText := CLR_BLACK
      o:nClrPane := CLR_WHITE
   endif

   // try to comment the line below 
   msginfo( "msgPaint :-))" ) 
return nil
 
if you put msginfo ( ... ) as comment the color change doesn't work.
I don't know why.

Regards, Detlef

Re: change color checkboxex on line

Posted: Wed Nov 13, 2024 7:51 am
by Silvio.Falconi
Detlef wrote:Hi Silvio,

here a strange eample:

Code: Select all | Expand

#include "fivewin.ch"


Function main()
   local oWnd
   local lChk := .f., oChk

   DEFINE WINDOW  oWnd

      @ 5, 12 CHECKBOX oChk VAR lChk;
         PROMPT "hi there";
         SIZE 85, 20 PIXEL;
         OF oWnd COLOR CLR_BLACK, CLR_WHITE ;
         ON CHANGE colorize( oChk, oWnd )

   ACTIVATE WINDOW oWnd

return nil

Function colorize( o, w )

   if eval( o:bSetGet )
      o:nClrText := CLR_WHITE
      o:nClrPane := CLR_BLUE
   else
      o:nClrText := CLR_BLACK
      o:nClrPane := CLR_WHITE
   endif

   // try to comment the line below 
   msginfo( "msgPaint :-))" ) 
return nil
 
if you put msginfo ( ... ) as comment the color change doesn't work.
I don't know why.

Regards, Detlef
nice
I tried with lchecked I saw on the class is METHOD lChecked() INLINE Eval( ::bSetGet ) and not understood why not worked


Now I tried on my dialog and not run !!

Code: Select all | Expand

   @ nRow, nCol CHECKBOX aGetRuote[1] VAR aChk PROMPT aRuote[1] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE  ON CHANGE colorize( aGetRuote[1], oDlg
Image


try the test

Code: Select all | Expand

#include "fivewin.ch"
#include "constant.ch"

Function main()
   local oDlg,oFont,oBold
   local aChk:={}
   local aGetRuote:= array(11)
   Local aRuote  := {"Bari","Cagliari","Firenze","Genova",;
                   "Milano","Napoli","Palermo","Roma","Torino",;
                   "Venezia","Nazionale"}
   local nRow:= 10
   local nCol:= 5
   local nInterlinea:= 20

 local nBottom   := 33
 local nRight    := 99
 local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
 local nHeight := nBottom * DLG_CHARPIX_H

    For n= 1 to Len( aRuote)
      aadd(aChk,{.f.,aRuote[n]})
    next

   DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 14
   DEFINE FONT oBold NAME "MS Sans Serif" SIZE 0, 12 BOLD
   DEFINE DIALOG  oDlg ;
      SIZE nWidth, nHeight  PIXEL TRUEPIXEL RESIZABLE ;
      TITLE "colorize check"     COLOR 0, CLR_WHITE FONT oFont


      @ nRow, nCol CHECKBOX aGetRuote[1] VAR aChk[1][1];
      PROMPT aRuote[1] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[1], oDlg )  UPDATE
      nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[2] VAR aChk[2][1];
      PROMPT aRuote[2] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[2], oDlg ) UPDATE
       nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[3] VAR aChk[3][1];
      PROMPT aRuote[3] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[3], oDlg ) UPDATE
        nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[4] VAR aChk[4][1];
      PROMPT aRuote[4] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[4], oDlg ) UPDATE
        nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[5] VAR aChk[5][1];
      PROMPT aRuote[5] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[5], oDlg ) UPDATE
       nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[6] VAR aChk[6][1];
      PROMPT aRuote[6] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[6], oDlg ) UPDATE
      nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[7] VAR aChk[7][1];
      PROMPT aRuote[7] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[7], oDlg ) UPDATE
       nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[8] VAR aChk[8][1];
      PROMPT aRuote[8] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[8], oDlg ) UPDATE
       nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[9] VAR aChk[9][1];
      PROMPT aRuote[9] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[9], oDlg ) UPDATE
       nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[10] VAR aChk[10][1];
      PROMPT aRuote[10] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[10], oDlg ) UPDATE
      nRow+=nInterlinea
       @ nRow, nCol CHECKBOX aGetRuote[11] VAR aChk[11][1];
      PROMPT aRuote[11] SIZE 85, 20 PIXEL OF oDlg COLOR CLR_BLACK, CLR_WHITE ;
      ON CHANGE colorize( aGetRuote[11], oDlg ) UPDATE


       ACTIVATE DIALOG oDlg

return nil

Function colorize( o, w )

   if eval( o:bSetGet )
      o:nClrText := CLR_WHITE
      o:nClrPane := CLR_BLUE
   else
      o:nClrText := CLR_BLACK
      o:nClrPane := CLR_WHITE
   endif

   // try to comment the line below
 *  msginfo( "msgPaint :-))" )
return nil
 
If Rem msginfo( "msgPaint :-))" ) not work !!!

Re: change color checkboxex on line

Posted: Wed Nov 13, 2024 8:37 am
by Silvio.Falconi
resolved on test above I add w:refresh(.f.) instead of message
even if in my dialog it still doesn't work and I don't understand why