FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Wrong radio- and checkbox-color using classname ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Wrong radio- and checkbox-color using classname ?
Posted: Thu Jan 15, 2015 01:38 AM
Hello,

setting colors of SAY and GET using classnames works fine.
For RADIOS and CHECKBOXES only works once on init. A change doesn't work ?

The same problem ( spanish ) ???
viewtopic.php?f=6&t=24846&p=134801&hilit=classname+tradio#p134801

Like You can see on the 2. screenshot, the values are changed, but not the color-painting.
Only on GET and SAY it works.



I added messages to the color-change

The value of nBColor changes on button-action.

MsgAlert( nBColor, ' classname "TRADIO" ' )
MsgAlert( nBColor, ' classname "TCHECKBOX" ' )


Changing on buttonaction the Background from RED to BLUE
Changing on buttonaction the Text from WHITE to YELLOW
( changed to test textcolor as well, before it was only WHITE )

The full sample-code :

Code (fw): Select all Collapse
// Button< Reset > uses TESTCOLOR( oDlg, nBColor1, nTxtColor1 ) // RED = 255, WHITE = 16777215
// Button< Color > uses TESTCOLOR( oDlg, nBColor2, nTxtColor2 ) // BLUE = 16711680, YELLOW = 65535

#include"fivewin.ch"

FUNCTION MAIN()
Local oDlg, oBrush, oFont[3], oBtn[3], oGet[3], aX[3], c_Path, c_Path1
Local nBColor1 := 255, nTxtColor1  := 16777215
Local nBColor2 := 16711680, nTxtColor2  := 65535
Local oSay1, cSay1 := "Test SAY-color", oRadio1, nRadio1 := 1, oCheck1, lCheck1 := .T.

c_path := cFilePath(GetModuleFileName( GetInstance() ) ) 
c_path1 := c_path + "BITMAPS\"

aX[1] := 1
aX[2] := 2
aX[3] := 3

DEFINE FONT oFont[1] NAME "Tahoma" SIZE 0, -12 BOLD
DEFINE FONT oFont[2] NAME "Tahoma" SIZE 0, -14 BOLD
DEFINE FONT oFont[3] NAME "Tahoma" SIZE 0, -16 BOLD

DEFINE BRUSH oBrush COLOR 16765090

DEFINE DIALOG oDlg SIZE 300, 220 ;
FONT  oFont[1] TITLE "Set colors from class-name"   

@ 10, 10 GET oGet[1]  VAR aX[1] SIZE 10, 12 OF oDlg  PICT "9" PIXEL RIGHT FONT oFont[1] UPDATE
@ 28, 10 GET oGet[2]  VAR aX[2] SIZE 12, 14 OF oDlg  PICT "9" PIXEL RIGHT FONT oFont[2] UPDATE
@ 48, 10 GET oGet[3]  VAR aX[3] SIZE 14, 16 OF oDlg  PICT "9" PIXEL RIGHT FONT oFont[3] UPDATE

@ 70, 10 SAY oSay1    VAR cSay1 SIZE 80, 12 OF oDlg  PIXEL FONT oFont[3] UPDATE

@ 10, 40 RADIO oRadio1 VAR nRadio1 ITEMS "One", "Two", "Three" _3D SIZE 30, 15 PIXEL UPDATE ;
HELPID 100, 101, 102 

@ 10, 90 CHECKBOX oCheck1 VAR lCheck1 PROMPT "&Checkbox" SIZE 50, 12 OF oDlg PIXEL FONT oFont[3] UPDATE

@ 90, 10 BTNBMP oBtn[1] OF oDlg ;
SIZE 40, 15 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Reset" ;
FILENAME c_path1 + "Reset.Bmp" ;
ACTION TESTCOLOR( oDlg, nBColor1, nTxtColor1 ) ;
FONT oFont[1]  ;
LEFT
oBtn[1]:lTransparent := .t.   
oBtn[1]:cToolTip =  { "Set old color","RESET", 1, CLR_BLACK, 14089979 }
oBtn[1]:SetColor( 0, )  

@ 90, 55 BTNBMP oBtn[2] OF oDlg ;
SIZE 40, 15 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Color" ;
FILENAME c_path1 + "Colors.Bmp" ;
ACTION  TESTCOLOR( oDlg, nBColor2, nTxtColor2 ) ;
FONT oFont[1]  ;
LEFT
oBtn[2]:lTransparent := .t.   
oBtn[2]:cToolTip =  { "Change color","SET COLOR", 1, CLR_BLACK, 14089979 }
oBtn[2]:SetColor( 0, )  

@ 90, 105 BTNBMP oBtn[3] OF oDlg ;
SIZE 40, 15 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Exit" ;
FILENAME c_path1 + "Exit.Bmp" ;
ACTION oDlg:End() ;
FONT oFont[1]  ;
LEFT
oBtn[3]:lTransparent := .t.   
oBtn[3]:cToolTip =  { "Exit color-test","EXIT", 1, CLR_BLACK, 14089979 }
oBtn[3]:SetColor( 0, )  

TESTCOLOR( oDlg, nBColor1, nTxtColor1 )

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT oDlg:SetBrush( oBrush )

oFont[1]:End()
oFont[2]:End()
oFont[3]:End()

RELEASE BRUSH oBrush 

RETURN NIL

// -------------

FUNCTION TESTCOLOR( oDlg, nBColor, nTxtColor )
LOCAL X := 1, cClassname, aItems := {}

// Get control-types and create array
// -----------------------------------------------
FOR X = 1 TO LEN(oDlg:aControls)
    cClassname := oDlg:aControls[X]:Classname()
    DEFAULT cClassname:="\\"
    IF cClassname <> "\\"
        // define Control-classes ( add needed controls )
        // ----------------------------------------------------------------
        IF cClassname = "TGET"
                //                            Class-name                                 ID          Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nid, " ", X } )
        ELSEIF cClassname = "TSAY"
                //                            Class-name                                 ID          Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nid, " ", X } )
        ELSEIF cClassname = "TRADIO"
                //                            Class-name                                 ID          Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nid, " ", X } )
        ELSEIF cClassname = "TCHECKBOX"
                //                            Class-name                                 ID          Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nid, " ", X } )
        ELSEIF cClassname = "TBTNBMP"
                //                            Class-name                                  ID   Button-text                               Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nId, oDlg:aControls[X]:cCaption, X } )
        ELSEIF cClassname = "TXBROWSE"
                FOR Y = 1 TO LEN( oDlg:aControls[X]:aHeaders )
                    TXT := TXT + RTRIM( oDlg:aControls[X]:aHeaders[Y] ) + "|"
                NEXT
                //                            Class-name                                  ID    Col-text  Pos
                AADD( aItems, { cClassname, oDlg:aControls[X]:nId, TXT,        X } )
        ENDIF
    ENDIF
    IF aItems[X][1] = "TGET" .or. aItems[X][1] = "TSAY"
        //MsgAlert( nBCoColor, "Get and Say" )
        oDlg:aControls[X]:Setcolor( nTxtColor, nBColor )
        oDlg:aControls[X]:Refresh()
    ENDIF
    IF aItems[X][1] = "TRADIO"
        MsgAlert( nBColor, ' classname "TRADIO" ' )
                oDlg:aControls[X]:SetColor( nTxtColor, nBColor )        
        oDlg:aControls[X]:Refresh()
    ENDIF
    IF aItems[X][1] = "TCHECKBOX"
        MsgAlert( nBColor, ' classname "TCHECKBOX" ' )
        oDlg:aControls[X]:Setcolor( nTxtColor, nBColor )
        oDlg:aControls[X]:Refresh()
    ENDIF
NEXT

RETURN NIL
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Wrong radio- and checkbox-color using classname ?
Posted: Fri Jan 16, 2015 05:30 AM

Uwe,

Try this:

oDlg:aControls[X]:oBrush:End()
oDlg:aControls[X]:SetColor( nTxtColor, nBColor )

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion