Dark-Mode and CHECKBOX

User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Dark-Mode and CHECKBOX

Post by Jimmy »

hi,

this is not a Fivewin Problem (also under Xbase++ or HMG)

i want to use "Dark-Mode" but than Caption on CHECKBOX are Black on Black ,,,
Image
but real it is
Image

like a (Push)-BUTTON i can not change Color when have "visual Style"

so my Question is : how to disable "visual Style" for CHECKBOX only :?:
greeting,
Jimmy
User avatar
Antonio Linares
Site Admin
Posts: 42655
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 67 times
Been thanked: 96 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by Antonio Linares »

Dear Jimmy,

Have you tried oCheckBox:SetColor( nClrForeground, nClrBackground ) ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Dark-Mode and CHECKBOX

Post by Jimmy »

hi Antonio,
Antonio Linares wrote:Have you tried oCheckBox:SetColor( nClrForeground, nClrBackground ) ?
No, i have used

Code: Select all | Expand

COLOR BFcolor, BGcolor
but Result is same
Image
the Caption is always BLACK so i change FG / BG for this Sample
Image
greeting,
Jimmy
User avatar
karinha
Posts: 7963
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 5 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by karinha »

Please post the code for testing.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Dark-Mode and CHECKBOX

Post by Giovany Vecchi »

Hello, not to be parameterizing object by object I created this function below.
I changed the DIALOG Class in Dialog.prg in the INITIALIZE method to call the function or call at Dialog initialization. oDlg:bInit := {||CTRLS_COLORS(oDlg)}

Code: Select all | Expand

FUNCTION CTRLS_COLORS(f_oDlgContainer)
   Local lc_aCtrls := {}, lc_iFor := 0
   Local lc_aItemsRadio := {}

   lc_aCtrls := f_oDlgContainer:aControls

   For lc_iFor := 1 To Len(lc_aCtrls)
      If ValType(lc_aCtrls[lc_iFor]) == "O"
         if lc_aCtrls[lc_iFor]:ClassName() == "TRADIO"

            aEval(lc_aCtrls[lc_iFor]:oRadMenu:aItems,;
               {|_oRadId|{SetWindowTheme(_oRadId:hWnd, "", "" ),;
                       _oRadId:SetColor(CLR_WHITE,nRgb(111,141,160))}})

               
         ElseIf lc_aCtrls[lc_iFor]:ClassName() == "TCHECKBOX" 
         
            SetWindowTheme(lc_aCtrls[lc_iFor]:hWnd, "", "" )
            lc_aCtrls[lc_iFor]:SetColor(CLR_WHITE,nRgb(111,141,160))

         EndIf
      EndIf
   Next

RETURN NIL
 
Image
User avatar
Antonio Linares
Site Admin
Posts: 42655
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 67 times
Been thanked: 96 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by Antonio Linares »

Dear Giovanny,

many thanks for sharing your solution

Could you please post a screenshot to see how the checkboxes look like ?

many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Dark-Mode and CHECKBOX

Post by Giovany Vecchi »

Hello Antonio. This function changes the CheckBox and RadioBox colors.

Image

I changed the tDialog class in the Initiate method to call automatically.
Image
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 11 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by nageswaragunupudi »

Mr. Giovany

Many Many Thanks.
In these forums, every day I keep learning from expert friends like you.

This was all what I knew till I saw your posting.

1) In non-themed applications, we can set any colors just like any other controls and that works perfectly.
2) In themed applications, we can set any background color but can not change the text color, which remains black.

From your post I learned the use of SetWindowTheme() function.

We will try to improve the FWH library to make this happen automatically, when user specifies the colors in COLOR clause, so that it works the same way whether the application is themed or not themed.

We need to do this for both windows and dialogs.

May also ask? Did you use SetWindowTheme() for any other purposes? And if so, can you share your results?

Thanks again.
Regards

G. N. Rao.
Hyderabad, India
User avatar
karinha
Posts: 7963
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 5 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by karinha »

Code: Select all | Expand

// C:\FWH\SAMPLES\SILVPREV.PRG - Example By Silvio Falconi.

#include "FiveWin.ch"
#include "constant.ch"

#define AS_MDICHILD  1
#define AS_DIALOG    2

STATIC oWnd

FUNCTION Main()

   DEFINE WINDOW oWnd TITLE "Test" MDI MENU BuildMenu()

   SET MESSAGE OF oWnd TO "test" CENTER NOINSET  2015

   ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION BuildMenu()

   LOCAL oMenu

   MENU oMenu 2015

      MENUITEM "Test"

      MENU
         MENUITEM "test" ACTION Previsioni()
      ENDMENU

      oMenu:AddMdi()

   ENDMENU

RETURN( oMenu )

FUNCTION Previsioni()

   LOCAL oDlg, oBar, oFont, oBrw, N
   LOCAL nBottom   := 44
   LOCAL nRight    := 110
   LOCAL nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   LOCAL nHeight := nBottom * DLG_CHARPIX_H
   LOCAL nClrText := CLR_BLACK
   LOCAL oGrp := Array( 2 )
   LOCAL cTitle := "Previsioni"
   LOCAL oProgress
   LOCAL oPrevisione
   LOCAL dprimadata, ntotali_records, primo
   LOCAL oItem1, oItem2
   LOCAL aData := {}
   LOCAL oPanel
   LOCAL aValues  := Array( 12 )
   LOCAL aGetChk  := Array( 12 )
   LOCAL aGet     := Array( 20 )
   LOCAL aRuote   := { "Bari", "Cagliari", "Firenze", "Genova", ;
                       "Milano", "Napoli", "Palermo", "Roma", "Torino", ;
                       "Venezia", "Nazionale", "Tutte" }

   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -14 BOLD

   DEFINE DIALOG oDlg TITLE "test" SIZE nWidth, nHeight  PIXEL ;
      COLOR CLR_BLACK, CLR_WHITE  RESIZABLE FONT oFont TRANSPARENT

   oDlg:lHelpIcon := .F.

   DEFINE BUTTONBAR oBar BUTTONSIZE 60, 30 _3DLOOK TOP OF oDlg 2015 NOBORDER

   oBar:SetFont( oFont )
   oBar:nClrText := CLR_HBLUE
   oBar:Adjust()

   DEFINE BUTTON OF oBar FILENAME "bitmaps\elabora.bmp" ;
      PROMPT " Elabora " LEFT ACTION  Elabora() GROUP

   DEFINE BUTTON OF oBar FILENAME "bitmaps\salva.bmp"   ;
      PROMPT " Salva " LEFT ACTION  Salva() GROUP

   DEFINE BUTTON OF oBar FILENAME "bitmaps\stampa.bmp"  ;
      PROMPT " Stampa " LEFT ACTION  Stampa() GROUP

   @ 20, 140 XBROWSE oBrw  PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

   SetupBrowsePrevisioni( oBrw )
   oBrw:CreateFromCode()

   oPanel = TScrollPanel():New( 40, 5, oBrw:nHeight - 200, oBrw:nLeft - 5, oDlg )
   oPanel:WinStyle( WS_BORDER, .F. )

   oDlg:bResized := < ||
   LOCAL oRect    := oDlg:GetCliRect()
   oBar:nWidth    := oRect:nRight
   oBrw:nWidth    := oRect:nRight - 290
   oBrw:nHeight   := oRect:nBottom - 45
   oPanel:nTop    := oRect:ntop + 40
   oPanel:nLeft   := oRect:nleft + 5
   oPanel:nBottom := oBrw:nHeight - 200
   oBar:refresh()

   FOR n = 1 TO Len( oPanel:aControls )
      oPanel:aControls[ n ]:Refresh()
   NEXT

   RETURN NIL
   >

   ACTIVATE DIALOG oDlg AS MDICHILD ;
      ON INIT ( CreateOption( oPanel, @aGet, @aValues, aRuote, @aGetChk ), ;
      oPanel:SetRange(), Eval( oDlg:bResized )   )

   oFont:End()

RETURN  NIL

FUNCTION CreatePanel( oDlg, oBrw, oPanel )

   oPanel = TScrollPanel():New( 40, 5, oDlg:nBottom - 60, oBrw:nLeft - 5, oDlg )
   oPanel:WinStyle( WS_BORDER, .F. )

RETURN oPanel

FUNCTION CreateOption( oPanel, aGet, aValues, aRuote, aGetChk )

   LOCAL nTop := 2
   LOCAL nCol := 5
   LOCAL nCol2 := 20
   LOCAL nSizew := 100
   LOCAL nSizeh := 18
   LOCAL oGrp, nChk := 0

   AFill( aValues, .F. )

   oPanel:AddText( 5, nCol, 100, 18, "Ruote attive", ,, .T., 0xC38B2B, , 1 )

   @ nTop,        ncol CHECKBOX aGetChk[ 1 ]  VAR aValues[ 1 ]   ;
      PROMPT aRuote[ 1 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY // SCROLL ADJUST

   @ nTop += 1.7, ncol CHECKBOX aGetChk[ 2 ]  VAR aValues[ 2 ]   ;
      PROMPT aRuote[ 2 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol CHECKBOX aGetChk[ 3 ]  VAR aValues[ 3 ]   ;
      PROMPT aRuote[ 3 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol CHECKBOX aGetChk[ 4 ]  VAR aValues[ 4 ]   ;
      PROMPT aRuote[ 4 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol CHECKBOX aGetChk[ 5 ]  VAR aValues[ 5 ]   ;
      PROMPT aRuote[ 5 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol CHECKBOX aGetChk[ 6 ]  VAR aValues[ 6 ]   ;
      PROMPT aRuote[ 6 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   nTop := 2

   @ nTop,        ncol2 CHECKBOX aGetChk[ 7 ]  VAR aValues[ 7 ]   ;
      PROMPT aRuote[ 7 ]   SIZE nSizew, nSizeh OF oPanel          ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol2 CHECKBOX aGetChk[ 8 ]  VAR aValues[ 8 ]   ;
       PROMPT aRuote[ 8 ]  SIZE nSizew, nSizeh OF oPanel          ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol2 CHECKBOX aGetChk[ 9 ]  VAR aValues[ 9 ]   ;
      PROMPT aRuote[ 9 ]  SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol2 CHECKBOX aGetChk[ 10 ] VAR aValues[ 10 ]  ;
      PROMPT aRuote[ 10 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol2 CHECKBOX aGetChk[ 11 ] VAR aValues[ 11 ]  ;
      PROMPT aRuote[ 11 ] SIZE nSizew, nSizeh OF oPanel           ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY  // SCROLL ADJUST

   @ nTop += 1.7, ncol2 CHECKBOX aGetChk[ 12 ] VAR aValues[ 12 ]  ;
      PROMPT aRuote[ 12 ] SIZE nSizew, nSizeh OF oPanel           ;
      ON CHANGE ( Select_All( aGetChk, aValues[ 12 ] ) )          ;
      UPDATE COLOR CLR_GRAY, CLR_HGRAY

RETURN NIL

FUNCTION Elabora()

   MsgInfo( "elabora" )

RETURN NIL

FUNCTION Salva()

   MsgInfo( "salva" )

RETURN NIL

FUNCTION stampa()

   MsgInfo( "stampa" )

RETURN NIL

STATIC FUNCTION Select_All( aGet, lValue )

   LOCAL n

   FOR n = 1 TO Len( aGet )
      aGet[ n ]:SetCheck( lValue )
   NEXT

RETURN NIL

STATIC FUNCTION SetupBrowsePrevisioni( oBrw )

   WITH OBJECT oBrw

      AEval( :aCols, {| o, i | o:cHeader := LTrim( Str( i, 2 ) ) } )

      :nEditTypes    := EDIT_GET
      :nWidths       := 24
      :lDrawBorder := .T.
      :lHscroll            := .T.
      :lVscroll            := .T.
      :l2007               := .F.
      :l2015               := .F.

      :lAllowRowSizing     := .F.
      :lAllowColSwapping   := .F.
      :lAllowColHiding     := .F.

      // NEW
      :lAllowSizings       := .F.
      :lAutoSaves          := .T.

      :lColDividerComplete := .F.

      :nClrBorder := CLR_GRAY

      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
      :bRecSelHeader    := {|| " " }
      :SetStyle( 2018 )

   END

RETURN NIL

// FIN / END
 
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Dark-Mode and CHECKBOX

Post by Giovany Vecchi »

Hi MR Hao.
My initial idea when I made this function was to put a real routine for themes.
Look. We can define a theme class to apply to all components (RadioBox, ComboBox, CheckBox etc) and then just call this function I posted. More Function has only CheckBox and RadioBox.
User avatar
Enrico Maria Giordano
Posts: 8770
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by Enrico Maria Giordano »

Please note that the look of the non-themed controls is very different (Windows-98-like!). So i strongly advise against that practice.
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 11 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by nageswaragunupudi »

Without making any changes to FWH library, we can have colored checkboxes even in a Themed application.

My test program:

darkwnd.prg

Code: Select all | Expand

#include "fivewin.ch"

function Main()

   local oWnd, oBtn, oCbx
   local lCheck   := .f.

   DEFINE WINDOW oWnd COLOR CLR_WHITE, CLR_BLACK ;
      TITLE "DARK THEME WINDOW"

   @ 20,20 SAY "DARK WINDOW " + If( IsAppThemed(), "THEMED", "NON-THEMED" ) ;
      SIZE 200,24 PIXEL OF oWnd

   @ 60,20 CHECKBOX oCbx VAR lCheck PROMPT "Check Box-01" SIZE 100,25 PIXEL OF oWnd ;
         COLOR CLR_HRED, CLR_YELLOW

   @ 150,20 BUTTON oBtn PROMPT "BUTTON" SIZE 100,40 PIXEL OF oWnd

   ACTIVATE WINDOW oWnd CENTERED

return nil
 
darkwnd.rc

Code: Select all | Expand

#ifndef __64__
  1 24 "WinXP/WindowsXP.Manifest"
#else
  1 24 "WinXP/WindowsXP.Manifest64"
#endif
 
Result:
Image

Can other any other users try this and confirm if they are getting the same results?

I am wondering why both themed and non-themed apps both look the same way if the checkbox is created on a window? Am I doing something wrong?

Dialog is different though.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Dark-Mode and CHECKBOX

Post by Jimmy »

hi,

you are right that i can change Background Color but not Foreground Color for Caption which is always BLACK
so i need "Ownerdraw" when using BLACK Background to "see" Caption
greeting,
Jimmy
User avatar
Enrico Maria Giordano
Posts: 8770
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Dark-Mode and CHECKBOX

Post by Enrico Maria Giordano »

The text is not red, this is the problem.
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Dark-Mode and CHECKBOX

Post by Jimmy »

karinha wrote:Please post the code for testing.

Regards, saludos.

Code: Select all | Expand

PRIVATE BGcolor      := RGB( 001, 001, 001 )                          // CLR_BLACK
PRIVATE BFcolor      := RGB( 025, 254, 255 )                          // CLR_CYAN

   DEFINE WINDOW oWnd FROM 0, 0 TO 290, 300 PIXEL TITLE "File attributes for " + cFile ICON "A1MAIN" NOMINIMIZE NOMAXIMIZE COLOR BFcolor, BGcolor

      @ 026, 14 CHECKBOX oFA_Check_1 VAR lArchive PROMPT "&Archive" SIZE 180, 16 PIXEL FONT oFontDefault OF oWnd
      @ 048, 14 CHECKBOX oFA_Check_2 VAR lReadOnly PROMPT "&Read only" SIZE 180, 16 PIXEL FONT oFontDefault OF oWnd
      @ 070, 14 CHECKBOX oFA_Check_3 VAR lHidden PROMPT "&Hidden" SIZE 180, 16 PIXEL FONT oFontDefault OF oWnd
      @ 092, 14 CHECKBOX oFA_Check_4 VAR lSystem PROMPT "&System" SIZE 180, 16 PIXEL FONT oFontDefault OF oWnd

      @ 130, 14 CHECKBOX oFA_Check_5 VAR lChange PROMPT "Change &date/time" SIZE 180, 16 PIXEL FONT oFontDefault OF oWnd

      oFA_Check_1:SetColor( BGcolor, BFcolor )
      oFA_Check_2:SetColor( BGcolor, BFcolor )
      oFA_Check_3:SetColor( BGcolor, BFcolor )
      oFA_Check_4:SetColor( BGcolor, BFcolor )
      oFA_Check_5:SetColor( BGcolor, BFcolor )

      @ 110, 206 BUTTON oFA_Button_3 PROMPT "C&urrent" SIZE 74, 42 PIXEL FONT oFontDefault ;
              ACTION( cDate := DTOC( DATE() ), oFA_Text_1:refresh(), ;
              cTime := TIME(), oFA_Text_2:refresh(), ;
              lChange := .t., oFA_Check_5:refresh() )

      @ 160, 014 GET oFA_Text_1 VAR cDate SIZE 120, 28 PIXEL FONT oFontDefault COLOR BFcolor, BGcolor OF oWnd        
      @ 160, 182 GET oFA_Text_2 VAR cTime SIZE 100, 28 PIXEL FONT oFontDefault COLOR BFcolor, BGcolor OF oWnd        

      @ 202, 014 BUTTON oFA_Button_2 PROMPT "&Cancel" SIZE 80, 42 PIXEL FONT oFontDefault ACTION oWnd:End()
      @ 202, 206 BUTTON oFA_Button_1 PROMPT "&Ok" SIZE 74, 42 PIXEL FONT oFontDefault ACTION( SetAttr( cPath + cFile, lArchive, lReadOnly, lHidden, lSystem, lChange, cDate, cTime ), oWnd:End() )

#IFDEF __HMG__
   END WINDOW
#ENDIF
greeting,
Jimmy
Post Reply