Einzelnen Beitrag anzeigen

Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.765 Beiträge
 
Delphi 11 Alexandria
 
#11

AW: Dark Theme aber nur die Farben

  Alt 2. Nov 2023, 14:36
Das scheint noch schlimmer zu sein, als ich dachte:
Hier https://www.codedotshow.com/blog/cod...the-dark-side/ beschreibt Ian Branch nochmal wie das mit der Theme Umschaltung funktioniert. Damals hatte schon einer gefragt, wie das denn ohne Themes ginge. Die Antwort lässt hinreichende Komplexität vermuten:
Zitat von Ian Branch:
Hi Alexandre – how you apply the style depends on whether or not the component is one which ‘understands’ styles and if it is FMX or VCL.

In most cases if you include the correct unit in your uses clause you can then call the TStyleManager to get the actual values for system colors and then use them to apply colors to the appropriate properties of any component which doesn’t support styles. If the component does support styles then you can create custom style elements and apply that element to the control.

To do things manually – If you are using VCL then in your uses clause make sure you have Vcl.Themes – for FireMonkey FMX make sure to include FMX.Styles instead (it is probably there already).

Now, somewhere in your formcreate code or similar have a routine like this:

AColor: TColor; // For VCL

or

AColor: TAlphaColor; // for FMX

Now you can do this:

AColor := TStyleManager.ActiveStyle.GetSystemColor(clBtnFace );

or

AColor := := TStyleManager.ActiveStyle.GetSystemColor(clHighlig ht);

etc etc – for any of the system colors.

Then you can use the AColor variable to assign a value to any of the component’s colors.
Das klappt so nicht bzw. hat keine sichtbare Wirkung. Hab das im FormCreate und in ApplicationEventsSettingChange.
Erst hier sieht man, das mehr dahinter steckt.
Zitat von Ian Branch:
You can see an example of this in the VCL – if you open VCL.Grids and navigate to the DrawCellBackground method you will see how they obtain and use the correct system colors, adjusted for the style.
Da steckt unglaublich viel Arbeit drin, die wirklich die VCL schon von Haus aus können sollte. Ein StringGrid reagiert trotzdem nicht auf hell dunkel Umschaltung.
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat