Dark mode

Dark mode

Postby Jimmy » Sun Oct 20, 2019 12:52 am

hi,

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

Image
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Dark mode

Postby joseluisysturiz » Sun Oct 20, 2019 8: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!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Dark mode

Postby Antonio Linares » Mon Oct 21, 2019 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dark mode

Postby Jimmy » Tue Oct 22, 2019 1:06 am

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 :!:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Dark mode

Postby Jimmy » Mon Oct 28, 2019 3:32 am

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
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Dark mode

Postby karinha » Sun Nov 14, 2021 2:21 pm

Jimmy, any solution?


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dark mode

Postby Jimmy » Mon Nov 15, 2021 6: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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Dark mode

Postby karinha » Mon Nov 15, 2021 12:45 pm

Thank you Jimmy.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dark mode

Postby nageswaragunupudi » Tue Nov 16, 2021 3: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: 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)
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby nageswaragunupudi » Tue Nov 16, 2021 9:44 am

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 } )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby karinha » 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: 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dark mode

Postby nageswaragunupudi » Tue Nov 16, 2021 3: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: 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby nageswaragunupudi » Tue Nov 16, 2021 3:41 pm

This function is included in the next version of FWH
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby nageswaragunupudi » Tue Nov 16, 2021 7:00 pm

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby karinha » Tue Nov 16, 2021 7: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: 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: MSN [Bot] and 39 guests