Recent

Author Topic: how to use SetSysColors?  (Read 1482 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 2895
Re: how to use SetSysColors?
« Reply #15 on: February 13, 2025, 03:32:23 pm »
PDB = PascalDragon B?
:D
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

robert rozee

  • Sr. Member
  • ****
  • Posts: 254
Re: how to use SetSysColors?
« Reply #16 on: February 13, 2025, 03:46:24 pm »
oh my... does that mean there are TWO of them!!!    8)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2641
Re: how to use SetSysColors?
« Reply #17 on: February 13, 2025, 11:15:15 pm »
oh my... does that mean there are TWO of them!!!    8)

No PascalDragon joined way later.

Anyway, MWE is indeed me and I had to dive into some archives to figure out who PDB was. My best guess it was Peter Dyson. He helped/submitted patches on  the WinApi at that time. I never had the idea that this would work system wide. It had to be done through some theme engine in the future (and then for application only)

Marc
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

robert rozee

  • Sr. Member
  • ****
  • Posts: 254
Re: how to use SetSysColors?
« Reply #18 on: February 14, 2025, 03:20:07 pm »
hi Marc,
    have you any ideas on how i can achieve the same effect as SetSysColors, but in a way that works?

what i am trying to do is to change all the system colours that an application loads, to a garish, clashing set. this is just for testing purposes, so that it is easy to spot 'style bugs' - where two controls are 'almost-the-same-colour-but-not-quite'. once instances are identified it then becomes possible to explore why/where a specific style bug originates.


cheers,
rob   :-)

zeljko

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: how to use SetSysColors?
« Reply #19 on: February 14, 2025, 04:50:36 pm »
hi Marc,
    have you any ideas on how i can achieve the same effect as SetSysColors, but in a way that works?

what i am trying to do is to change all the system colours that an application loads, to a garish, clashing set. this is just for testing purposes, so that it is easy to spot 'style bugs' - where two controls are 'almost-the-same-colour-but-not-quite'. once instances are identified it then becomes possible to explore why/where a specific style bug originates.


cheers,
rob   :-)

For Qt, you can change default QApplication_palette(), under gtk2/3 default css or default style colors. SetSysColors does not work as it works under ms windows. Even if you change sys color to some other value nothing happens to the widgets, unless you override default palette/style colors.

robert rozee

  • Sr. Member
  • ****
  • Posts: 254
Re: how to use SetSysColors?
« Reply #20 on: February 14, 2025, 05:18:31 pm »
For Qt, you can change default QApplication_palette(), under gtk2/3 default css or default style colors. SetSysColors does not work as it works under ms windows. Even if you change sys color to some other value nothing happens to the widgets, unless you override default palette/style colors.

if that worked, it would be great. but these are colours that a GUI application retrieves from the Desktop Manager when the application is run. they are not staticaly coded into the binary executable.

are you able to elaborate or explain a little more about this 'default css'? i am using the GTK2 widgetset, ie the lazarus default.


cheers,
rob   :-)

zeljko

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: how to use SetSysColors?
« Reply #21 on: February 14, 2025, 06:20:25 pm »
css is gtk3, widget style is gtk2, QPalette is qt4,5,6. If you change colors in application default style then all newly created widgets will use that colors if LCLControl.Color := clDefault. eg if you override background color in gtk2 style for windows from clForm to clRed, then all new forms will be colored red by default. I really don't know how to exactly change gtk2 colors for application globally, but I know where to look (haven't played with gtk2 stuff for years).

robert rozee

  • Sr. Member
  • ****
  • Posts: 254
Re: how to use SetSysColors?
« Reply #22 on: February 14, 2025, 06:51:01 pm »
[...] widget style is gtk2 [...] If you change colors in application default style then all newly created widgets will use that colors if LCLControl.Color := clDefault. eg if you override background color in gtk2 style for windows from clForm to clRed, then all new forms will be colored red by default. I really don't know how to exactly change gtk2 colors for application globally, but I know where to look (haven't played with gtk2 stuff for years).

yes... where is "gtk2 style" located? how can it be accessed? you are right that i am interested in the case where a control's colour property is set to clDefault. i just need a means to access the lookup tables that translate clDefault for each control type into an RGB value that has been (on application startup) retrieved from the Window Manager's currently set Theme.

"I know where to look" - please, do tell me where to look?


cheers,
rob   :-)

zeljko

  • Hero Member
  • *****
  • Posts: 1718
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: how to use SetSysColors?
« Reply #23 on: February 14, 2025, 07:34:53 pm »
gtk2proc.pas function GetStyle(aStyle: TLazGtkStyle): PGTKStyle;, function GetStyleWidget(aStyle: TLazGtkStyle): PGTKWidget;   etc, gtk2themes.pas, gtk2widgetset.inc look at procedure TGtk2WidgetSet.InitSystemColors; ....etc.
https://stackoverflow.com/questions/99488/how-do-i-change-the-colors-of-an-arbitrary-widget-in-gtk etc etc...

robert rozee

  • Sr. Member
  • ****
  • Posts: 254
Re: how to use SetSysColors?
« Reply #24 on: February 15, 2025, 02:21:35 pm »
gtk2proc.pas function GetStyle(aStyle: TLazGtkStyle): PGTKStyle;, function GetStyleWidget(aStyle: TLazGtkStyle): PGTKWidget;   etc, gtk2themes.pas, gtk2widgetset.inc look at procedure TGtk2WidgetSet.InitSystemColors; ....etc.
https://stackoverflow.com/questions/99488/how-do-i-change-the-colors-of-an-arbitrary-widget-in-gtk etc etc...

just spent an evening + half the night digging into this - too many layers of abstraction to make any sense of it!

have got as far as UpdateSysColorMap(TForm, Lgs); where Lgs is of type TLazGtkStyle, but i can't find out what unit to include to bring in the definition of TLazGtkStyle. also, i'm not entirely sure if i'm not barking up the wrong tree with UpdateSysColorMap and am close to the point of throwing in the towel on this one.


cheers,
rob   :-)

 

TinyPortal © 2005-2018