I wanted to change the textcolor of RADIOS and CHECKBOXES at runtime.
It only works on SAY
FUNCTION OBJ_UPDATE( oFld2, nTextColor, nBackColor )
// FOLDER
AEval( oFld2:aDialogs[ 2 ]:aControls, { |o| IF( o:ClassName == "TSAY", o:SetColor( nTextColor, nBackColor ), NIL ), ; // works !!!
IF( o:ClassName == "TRADIO", o:nClrText := nTextColor, NIL ), ;
IF( o:ClassName == "TCHECKBOX", o:SetColor( nTextColor, nBackColor ), NIL ), ;
o:Refresh() } )
// DIALOG
AEval( oDlgMain:aControls, { |o| IF( o:ClassName == "TSAY", o:SetColor( nTextColor, nBackColor ), NIL ), ; // works !!!
IF( o:ClassName == "TRADIO", o:nClrText := nTextColor, NIL ), ;
IF( o:ClassName == "TCHECKBOX", o:SetColor( nTextColor, nBackColor ), NIL ), ;
o:Refresh() } )
RETURN( NIL )
Test on DIALOG and FOLDER
is it possible ( colorchange on button-action ) ?
The complete test
If You want to include it in the sample-collector
please delete this line in < SAMPLES.prg > function
// -------- FOLDER - Backgrounds ---------------
FUNCTION F_BACKGRD( oFld, lTransp )
...
...
// there is a fixed textcolor defined
AEval( oDlg:aControls, { |o| IF( o:ClassName == "TSAY", ( o:SetColor( 0, 13885951 ), o:Refresh() ), NIL ) } )
add to < CODE_2.prg > function < GRPC2_SEC2( oFld2, nSavePage ) >
delete the < NO SAMPLE > message
- Code: Select all Expand view
// ----------------------- GROUP 2 Page 2 -------------------------------------
FUNCTION GRPC2_SEC2( oFld2, nSavePage )
LOCAL oSay[4], nTextColor := 255, nBackColor := 3926784, oBtn1, oBtn2
LOCAL oRadio1, oRadio2, nRadio := 1, oCheck1, oCheck2, lCheck := .F.
//MsgAlert( "Folder-page 2 with GRADIENT", "Attention" )
@ 15, 30 SAY oSay[1] PROMPT " SAY - colortest " SIZE 240, 30 FONT oLarge OF oFld2:aDialogs[ 2 ] PIXEL
oSay[1]:SetColor( nTextColor, nBackColor ) // Red text on Green
@ 55, 30 SAY oSay[2] PROMPT " SAY - transp.test " SIZE 250, 30 FONT oLarge OF oFld2:aDialogs[ 2 ] ;
PIXEL TRANSPARENT
oSay[2]:SetColor( nTextColor, ) // Red text
@ 100, 30 RADIO oRadio1 VAR nRadio ITEMS "&One", "&Two", "T&hree" _3D SIZE 50, 12 ;
HELPID 100, 101, 102 OF oFld2:aDialogs[ 2 ] PIXEL UPDATE
AEval( oRadio1:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oMedium ), ;
oRad:nClrText := nTextColor } )
@ 100, 100 CHECKBOX oCheck1 VAR lCheck PROMPT " Checkbox" SIZE 70, 9 OF oFld2:aDialogs[ 2 ] FONT oMedium PIXEL
oCheck1:SetColor( nTextColor, ) // Red text
oCheck1:lTransparent := .T.
// ------------- The DIALOG-area -------------
@ 440, 80 SAY oSay[3] PROMPT " SAY - colortest " SIZE 470, 60 FONT oLarge OF oDlgMain PIXEL
oSay[3]:SetColor( nTextColor, nBackColor ) // Red text on Green
@ 520, 80 SAY oSay[4] PROMPT " SAY - transp.test " SIZE 480, 60 FONT oLarge OF oDlgMain ;
PIXEL TRANSPARENT
oSay[4]:SetColor( nTextColor, ) // Red text
@ 590, 80 RADIO oRadio2 VAR nRadio ITEMS "&One", "&Two", "T&hree" _3D SIZE 70, 25 ;
HELPID 100, 101, 102 OF oDlgMain PIXEL UPDATE
AEval( oRadio2:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oMedium ), ;
oRad:nClrText := nTextColor } )
@ 595, 210 CHECKBOX oCheck2 VAR lCheck PROMPT " Checkbox" SIZE 120, 12 OF oDlgMain FONT oMedium PIXEL
oCheck2:SetColor( nTextColor, ) // Red text
oCheck2:lTransparent := .T.
// -------------
@ 450, 670 BTNBMP oBtn1 OF oDlgMain ;
SIZE 120, 40 PIXEL 2007 ;
NOBORDER ;
PROMPT " &Text " ;
FILENAME c_Path1 + "PAINT.bmp" ;
ACTION ( nTextColor := ChooseColor(), ;
OBJ_UPDATE( oFld2, nTextColor, nBackColor ) ) ;
FONT oSFont ;
LEFT
@ 520, 670 BTNBMP oBtn2 OF oDlgMain ;
SIZE 120, 40 PIXEL 2007 ;
NOBORDER ;
PROMPT " &Backgrd. " ;
FILENAME c_Path1 + "PAINT.bmp" ;
ACTION ( nBackColor := ChooseColor(), ;
OBJ_UPDATE( oFld2, nTextColor, nBackColor ) ) ;
FONT oSFont ;
LEFT
RETURN NIL
// --------------
FUNCTION OBJ_UPDATE( oFld2, nTextColor, nBackColor )
AEval( oFld2:aDialogs[ 2 ]:aControls, { |o| IF( o:ClassName == "TSAY", o:SetColor( nTextColor, nBackColor ), NIL ), ;
IF( o:ClassName == "TRADIO", o:nClrText := nTextColor, NIL ), ;
IF( o:ClassName == "TCHECKBOX", o:SetColor( nTextColor, nBackColor ), NIL ), ;
o:Refresh() } )
AEval( oDlgMain:aControls, { |o| IF( o:ClassName == "TSAY", o:SetColor( nTextColor, nBackColor ), NIL ), ;
IF( o:ClassName == "TRADIO", o:nClrText := nTextColor, NIL ), ;
IF( o:ClassName == "TCHECKBOX", o:SetColor( nTextColor, nBackColor ), NIL ), ;
o:Refresh() } )
SYSREFRESH()
RETURN( NIL )
regards
Uwe