FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Dark mode
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Dark mode

Posted: Sun Oct 20, 2019 12:52 AM
hi,

is there a FW Sample using "Dark Mode" :-)

greeting,

Jimmy
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM

Re: Dark mode

Posted: Sun Oct 20, 2019 08:53 PM

Sakudos, aiempre he querodps hacer mis sistemas asi, pero no conseguido como, gracias... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Dark mode

Posted: Mon Oct 21, 2019 04:03 AM

Jimmy,

If your app is going to use a RibbonBar here you have the source code to build a "dark" RibbonBar:

viewtopic.php?p=221683#p221683

Using these colors and applying them to your app you should get the desired "dark" app

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: Dark mode

Posted: Tue Oct 22, 2019 01:06 AM
hi,
joseluisysturiz wrote:Sakudos, aiempre he querodps hacer mis sistemas asi, pero no conseguido como, gracias... :-)

when using Ownerdraw you can react on visual Style / Effekt and paint what you want.

so the Question is does FW Controls support Ownerdraw :-)

---
do you remember Color under Windows XP ?


Color of Apps depend on OS Theme which can be found in Registry under
Code (fw): Select all Collapse
HKEY_CURRENT_USER\Control Panel\Colors


there are COLOR_ Constant to use it with GetSysColor() / SetSysColors() API

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getsyscolor
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setsyscolors

using SetSysColors() will change Color for all Apps :-) but only as long as User is login.
after re-login OS load default so Registry is not change :-)
greeting,

Jimmy
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: Dark mode

Posted: Mon Oct 28, 2019 03:32 AM
hi,

i found this working Code
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=17578&p=91694&hilit=SETSYSCOLORS#p91694

Code (fw): Select all Collapse
nRet := clrtest( CLR_YELLOW, CLR_HRED )

HB_FUNC( CLRTEST )
{
   int aElements[2] = { COLOR_CAPTIONTEXT, COLOR_SCROLLBAR };
   DWORD aColors[2];

   aColors[ 0 ] = hb_parnl( 1 );
   aColors[ 1 ] = hb_parnl( 2 );
   hb_retl (SetSysColors( 2, aElements, aColors ));
}


now i try this code with modify Function and it work
Code (fw): Select all Collapse
nRet := SETSYSCOLORSEX({COLOR_SCROLLBAR}, CLR_HMAGENTA)
nRet := SETSYSCOLORSEX({COLOR_CAPTIONTEXT},CLR_HBLUE)

HB_FUNC( SETSYSCOLORSEX )
{
   int aElements[1];
   DWORD aColors[1];

   aElements[ 0 ] = hb_parnl( 1 );
   aColors[ 0 ]   = hb_parnl( 2 );
   hb_retl (SetSysColors( 1, aElements, aColors ));
}

but this function have only 2 Parameter and it start with Array.
what i like to have are 3 Parameter where 2nd and 3rd are test for "VALTYPE" = "C" or "A"

who can help me to write a new SETSYSCOLORSEX :-)

p.s. not sure if Answer is like this Thread http://forums.fivetechsupport.com/viewtopic.php?f=6&t=28506&p=159545
greeting,

Jimmy
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Dark mode

Posted: Sun Nov 14, 2021 02:21 PM

Jimmy, any solution?

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: Dark mode

Posted: Mon Nov 15, 2021 06:18 AM
hi,

have to say that i still work with HMG ... still Newbie under harbour
most of my HMG Apps now have "DarkMode" but as HMG have no "OwnerDraw" i can not "paint" black all.
special "Background" like WM_CTLCOLORSTATIC need "more" Code to handle it

to "manipulate" those "System-Color" does work "System-wide" so some "other" App does not like Color (black on black) :-)

---

i do have other Tool called "Codejock SkinFrameWork"
https://codejock.com/products/skinframework/?2yn6s14z=p1z
i bought it Years ago to "learn" about ActiveX but only SkinFrameWork is left (other i have re-write as native Control for Xbase++ )

SkinFrameWork can "load" a Theme "just" for "the" App
as it is for "only" that App it does not "hurt" other App and i can use "my" Color
greeting,

Jimmy
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Dark mode

Posted: Mon Nov 15, 2021 12:45 PM

Thank you Jimmy.

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: Tue Nov 16, 2021 03:39 AM
using SetSysColors() will change Color for all Apps :-) but only as long as User is login.

Only with Windows Versions prior to 10.

From Windows 10 onwards, the functions SetSysColors() may not be of much use.

For Windows 10, setting this registry entry
Code (fw): Select all Collapse
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme

to 0 sets dark theme ON. But this applies to UWP applications only and not to classic win32 applications. We can see the difference in applications like Explorer, Calculator, etc but not with Notepad, etc.

So,

We need to adopt 2 different approaches for OS upto Windows 8.1 and for OS Windows 10 and later. For older versions we can use SetSysColors()
For W10 and later, we still don't have clear answers.

Using FWH, we can draw most controls in Dark Mode using SetColor or ownerdraw but not all (Eg. Scrollbars, dialog/window borders, etc)
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Dark mode

Posted: Tue Nov 16, 2021 09:44 AM
Code (fw): Select all Collapse
#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_parvni( 1, i );
         aRgbValues[ i - 1 ]  = hb_parvnl( 2, i );
         bRet  = SetSysColors( iElements, aElements, aRgbValues );
      }
   }
   hb_retl( bRet );
}

#pragma ENDDUMP


Testing the function:
Code (fw): Select all Collapse
   ? SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, { CLR_BLACK, CLR_WHITE } )
Regards



G. N. Rao.

Hyderabad, India
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Dark mode

Posted: Tue Nov 16, 2021 12:13 PM
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=41065&sid=3ac19fbcf1d34a23eaf18df0660ae40e

// \samples\DARKMODE.PRG - En windows 7 32 bits, no funciona.

/*
In xHarbour, Error:

DARKMODE.c:
Warning W8065 DARKMODE.prg 59: Call to function 'hb_parvni' with no prototype in
function HB_FUN_SETSYSCOLORS
Warning W8065 DARKMODE.prg 60: Call to function 'hb_parvnl' with no prototype in
function HB_FUN_SETSYSCOLORS
*/

Code (fw): Select all Collapse
#Include "FiveWin.ch"

#Define COLOR_WINDOW     nRGB( 130, 130, 130 )
#Define COLOR_WINDOWTEXT nRGB( 130, 130, 130 )

STATIC oWnd

FUNCTION Main()

   // RETORNA: .T. => TRUE.
   // ? SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, { CLR_BLACK, CLR_WHITE } )

   LOCAL oBar, cTitle, nRet

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

   DEFINE WINDOW oWnd TITLE cTitle COLORS CLR_WHITE, CLR_WHITE

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( Finaliza() )

   SET MESSAGE OF oWnd TO cTitle NOINSET CLOCK DATE KEYBOARD

   // SetSysColors - Harbour Compila, mas NO FUNCIONA Master Nages.
   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT( SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, ;
                             { CLR_WHITE, CLR_WHITE } ) )

RETURN NIL

FUNCTION Finaliza()

   oWnd:End()

RETURN NIL

#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_parvni( 1, i );
         aRgbValues[ i - 1 ]  = hb_parvnl( 2, i );
         bRet  = SetSysColors( iElements, aElements, aRgbValues );
      }
   }
   hb_retl( bRet );
}

#pragma ENDDUMP

// 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: Tue Nov 16, 2021 03:40 PM
karinha wrote:http://forums.fivetechsupport.com/viewtopic.php?f=6&t=41065&sid=54ad898a54718ceb4499289b28c0db17

// \samples\DARKMODE.PRG - En windows 7 32 bits, no funciona.

/*
In xHarbour, Error:

DARKMODE.c:
Warning W8065 DARKMODE.prg 59: Call to function 'hb_parvni' with no prototype in
function HB_FUN_SETSYSCOLORS
Warning W8065 DARKMODE.prg 60: Call to function 'hb_parvnl' with no prototype in
function HB_FUN_SETSYSCOLORS
*/

Code (fw): Select all Collapse
#Include "FiveWin.ch"

#Define COLOR_WINDOW     nRGB( 130, 130, 130 )
#Define COLOR_WINDOWTEXT nRGB( 130, 130, 130 )

STATIC oWnd

FUNCTION Main()

   // RETORNA: .T. => TRUE.
   // ? SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, { CLR_BLACK, CLR_WHITE } )

   LOCAL oBar, cTitle, nRet

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

   DEFINE WINDOW oWnd TITLE cTitle COLORS CLR_WHITE, CLR_WHITE

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( Finaliza() )

   SET MESSAGE OF oWnd TO cTitle NOINSET CLOCK DATE KEYBOARD

   // SetSysColors - Harbour Compila, mas NO FUNCIONA Master Nages.
   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT( SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, ;
                             { CLR_WHITE, CLR_WHITE } ) )

RETURN NIL

FUNCTION Finaliza()

   oWnd:End()

RETURN NIL

#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_parvni( 1, i );
         aRgbValues[ i - 1 ]  = hb_parvnl( 2, i );
         bRet  = SetSysColors( iElements, aElements, aRgbValues );
      }
   }
   hb_retl( bRet );
}

#pragma ENDDUMP

// FIN / END


Regards, saludos.

For xHarbour change hb_parvni as hb_parni and hb_parvnl as hb_parnl
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Dark mode

Posted: Tue Nov 16, 2021 03:41 PM

This function is included in the next version of FWH

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Dark mode

Posted: Tue Nov 16, 2021 07:00 PM
Supported by All Versions of Windows
Code (fw): Select all Collapse
COLOR_BTNFACE                15
COLOR_BTNTEXT                18
COLOR_GRAYTEXT               17  // disabled text
COLOR_HIGHLIGHT              13
COLOR_WINDOW                  5  // window background
COLOR_WINDOWTEXT              8  // window text


NOT SUPPORTED BY WINDOWS 10 AND LATER.
Some are not supported even on Windows 2000
Code (fw): Select all Collapse
COLOR_SCROLLBAR               0
COLOR_BACKGROUND              1
COLOR_ACTIVECAPTION           2
COLOR_INACTIVECAPTION         3
COLOR_MENU                    4
COLOR_WINDOWFRAME             6
COLOR_MENUTEXT                7
COLOR_CAPTIONTEXT             9
COLOR_ACTIVEBORDER           10
COLOR_INACTIVEBORDER         11
COLOR_APPWORKSPACE           12  // desktop
COLOR_HIGHLIGHTTEXT          14
COLOR_BTNSHADOW              16
COLOR_INACTIVECAPTIONTEXT    19
COLOR_BTNHIGHLIGHT           20
COLOR_3DDKSHADOW             21
COLOR_3DLIGHT                22
Regards



G. N. Rao.

Hyderabad, India
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: Dark mode

Posted: Tue Nov 16, 2021 07:43 PM
Mister Nages, perfect! The window goes all black. Now I need to Change the WINDOW TITLE COLOR. Where it is written:

"RODRIGUES & AMORIM MECANICA LTDA".

Also check that when it is an MDI Window, it is not BLACK but OPAQUE. Excellent work, you are on the right path. Thanks.

Code (fw): Select all Collapse
// \samples\DARKMODE.PRG - 16/11/2021 - Joao.

#Include "FiveWin.ch"

#Define COLOR_BTNFACE                15
#Define COLOR_BTNTEXT                18
#Define COLOR_GRAYTEXT               17  // disabled text
#Define COLOR_HIGHLIGHT              13
#Define COLOR_WINDOW                  5  // window background
#Define COLOR_WINDOWTEXT              8  // window text

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_WINDOWTEXT, COLOR_WINDOW  }, ;
                             { CLR_BLACK, CLR_BLACK } ) )

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