Dark mode

Re: Dark mode

Postby karinha » Tue Nov 16, 2021 7: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
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dark mode

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby Jimmy » 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: Select all  Expand view
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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Dark mode

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Dark mode

Postby karinha » 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: Select all  Expand view

// \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
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dark mode

Postby nageswaragunupudi » Wed Nov 17, 2021 2: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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests