Page 1 of 2

Dark mode

PostPosted: Sun Oct 20, 2019 12:52 am
by Jimmy
hi,

is there a FW Sample using "Dark Mode" :?:

Image

Re: Dark mode

PostPosted: Sun Oct 20, 2019 8:53 pm
by joseluisysturiz
Sakudos, aiempre he querodps hacer mis sistemas asi, pero no conseguido como, gracias... :shock:

Re: Dark mode

PostPosted: Mon Oct 21, 2019 4:03 am
by Antonio Linares
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

Re: Dark mode

PostPosted: Tue Oct 22, 2019 1:06 am
by Jimmy
hi,
joseluisysturiz wrote:Sakudos, aiempre he querodps hacer mis sistemas asi, pero no conseguido como, gracias... :shock:

when using Ownerdraw you can react on visual Style / Effekt and paint what you want.
Image
so the Question is does FW Controls support Ownerdraw :?:

---
do you remember Color under Windows XP ?
Image

Color of Apps depend on OS Theme which can be found in Registry under
Code: Select all  Expand view
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 :!:

Re: Dark mode

PostPosted: Mon Oct 28, 2019 3:32 am
by Jimmy
hi,

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

Code: Select all  Expand view
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: Select all  Expand view
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

Re: Dark mode

PostPosted: Sun Nov 14, 2021 2:21 pm
by karinha
Jimmy, any solution?


Regards, saludos.

Re: Dark mode

PostPosted: Mon Nov 15, 2021 6:18 am
by Jimmy
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

Re: Dark mode

PostPosted: Mon Nov 15, 2021 12:45 pm
by karinha
Thank you Jimmy.

Regards, saludos.

Re: Dark mode

PostPosted: Tue Nov 16, 2021 3:39 am
by nageswaragunupudi
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: Select all  Expand view

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)

Re: Dark mode

PostPosted: Tue Nov 16, 2021 9:44 am
by nageswaragunupudi
Code: Select all  Expand view
#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: Select all  Expand view
  ? SetSysColors( { COLOR_WINDOW, COLOR_WINDOWTEXT }, { CLR_BLACK, CLR_WHITE } )
 

Re: Dark mode

PostPosted: Tue Nov 16, 2021 12:13 pm
by karinha
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: Select all  Expand view

#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.

Re: Dark mode

PostPosted: Tue Nov 16, 2021 3:40 pm
by nageswaragunupudi
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: Select all  Expand view

#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

Re: Dark mode

PostPosted: Tue Nov 16, 2021 3:41 pm
by nageswaragunupudi
This function is included in the next version of FWH

Re: Dark mode

PostPosted: Tue Nov 16, 2021 7:00 pm
by nageswaragunupudi
Supported by All Versions of Windows
Code: Select all  Expand view
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: Select all  Expand view
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
 

Re: Dark mode

PostPosted: Tue Nov 16, 2021 7:43 pm
by karinha
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: Select all  Expand view

// \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.