FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Dark mode
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Dark mode
Posted: Tue Nov 16, 2021 07:52 PM

Mister Nages, in time: when changing the window color, this has a side effect in other applications. For example: the google chrome page is completely black. Its power is incredible, Mister Nages. See if you can avoid this by closing the program window, perhaps keeping the original colors and restoring on exit. Just an idea.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Dark mode
Posted: Wed Nov 17, 2021 12:12 AM
Which version of Windows are you using?

You need not include individual COLOR_* defines in your program. Just include "wcolors.ch", which contains all these defines.


Now I need to Change the WINDOW TITLE COLOR. Where it is written:


Assign your colors to COLOR_ACTIVECAPTION, COLOR_INACTIVECAPTION, COLOR_CAPTIONTEXT, COLOR_INACTIVECAPTIONTEXT.

Please note that these changes will work only with Windows XP to 8.1.
This does not work with Windows 10 and later.

So, if you write your applications to be used only on older OS like Windows XP to Windows 8.1, then you can use "SetSysColors" to set your own theme, Dark or something else. Your applications will not get the desired effect on Windows 10 and later.

The point I am trying to make is that if you read any articles or advices to use SetSysColors() to implement DarkTheme, they are all old and obsolete. If we proceed in this direction, we are only wasting our time.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Dark mode
Posted: Wed Nov 17, 2021 10:00 AM
hi,

Color for Titlebar under Windows 10 /11 now called "Accent-Color"
you reach it under "personize" -> "Color"
you also need to enable Color for "Titlebar & Frame"

in Registry you will find it under
Code (fw): Select all Collapse
Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM
AccentColor


---

you can GetSysColor() and save Value before use SetSysColor()
i do load Information like Color from DBF or INI File at Start
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Dark mode
Posted: Wed Nov 17, 2021 11:30 AM
you also need to enable Color for "Titlebar & Frame"

how can we do this?

For Windows 10 we need to know how to set these colors
COLOR_ACTIVECAPTION, COLOR_INACTIVECAPTION, COLOR_CAPTIONTEXT, COLOR_INACTIVECAPTIONTEXT, COLOR_SCROLLBAR
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Dark mode
Posted: Wed Nov 17, 2021 11:53 AM
I give up. This is very complicated and may cause me a problem with customers. Even so, very obliging Mister Nages.

Code (fw): Select all Collapse
// \samples\DARKMODE.PRG - 17/11/2021 - Joao. Windows 7 32 Bits.

#Include "FiveWin.ch"
#Include "wColors.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oBar, cTitle, nRet

   cTitle := "RODRIGUES & AMORIM MECANICA LTDA"  // WHITE NO FUNCIONA.

   DEFINE WINDOW oWnd TITLE cTitle // MDI ?? NO FUNCIONA NORMAL.

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( Finaliza() )

   SET MESSAGE OF oWnd TO cTitle NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT( SetSysColors( { COLOR_ACTIVECAPTION, COLOR_INACTIVECAPTION  }, ;
                             { COLOR_CAPTIONTEXT, COLOR_INACTIVECAPTIONTEXT } ) )

RETURN NIL

FUNCTION Finaliza()

   oWnd:End()

RETURN NIL

#IFDEF __XHARBOUR__  // Modificado em: 16/11/2021 - Joao

// if xHarbour -> Nages:
// For xHarbour change hb_parvni as hb_parni and hb_parvnl as hb_parnl

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

HB_FUNC( SETSYSCOLORS ) // ( aItems, aColors ) --> lSuccess
{
   BOOL     bRet        = FALSE;
   int      iElements;
   INT      aElements[22];
   COLORREF aRgbValues[22];

   if ( ( iElements = hb_parinfa( 1, 0 ) ) == ( int ) hb_parinfa( 2, 0 ) )
   {
      int i;
      for ( i = 1; i <= iElements; i++ )
      {
         aElements [ i - 1 ]  = hb_parni( 1, i );
         aRgbValues[ i - 1 ]  = hb_parnl( 2, i );
         bRet  = SetSysColors( iElements, aElements, aRgbValues );
      }
   }
   hb_retl( bRet );
}

#pragma ENDDUMP

#ELSE

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

// if harbour
HB_FUNC( SETSYSCOLORS ) // ( aItems, aColors ) --> lSuccess
{
   BOOL     bRet        = FALSE;
   int      iElements;
   INT      aElements[22];
   COLORREF aRgbValues[22];

   if ( ( iElements = hb_parinfa( 1, 0 ) ) == ( int ) hb_parinfa( 2, 0 ) )
   {
      int i;
      for ( i = 1; i <= iElements; i++ )
      {
         aElements [ i - 1 ]  = hb_parvni( 1, i );
         aRgbValues[ i - 1 ]  = hb_parvnl( 2, i );
         bRet  = SetSysColors( iElements, aElements, aRgbValues );
      }
   }
   hb_retl( bRet );
}

#pragma ENDDUMP

#ENDIF

// FIN / END


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Dark mode
Posted: Wed Nov 17, 2021 02:15 PM
I give up. This is very complicated and may cause me a problem with customers. Even so, very obliging Mister Nages.

Yes.
I too would not use this approach in my applications.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion