![]() |
AW: Property eines TObjects setzen Frage
Wenn du jetzt noch in denn Projektoptionen | Application | Manifest | Enable Runtime Themes aktivierst, sieht es nicht mehr so aus wie vor 15 Jahren.
|
AW: Property eines TObjects setzen Frage
Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:
|
AW: Property eines TObjects setzen Frage
Zitat:
Du hast im Thread (Windows 10+ Dark/Light in Application.) Zitat:
Delphi-Quellcode:
Prop.SetValue(AObject, FTextColor);
Die Fontfarbe vom Control zu setzen. Warum bitte schön verwendest du dann nicht auch GetImmersiveColorFromColorSetEx Dafür ist es gedacht! ImmersiveColor vom System für das jeweilige Control holen und diese Farbe setzen. Siehe auch GetThemeSysColor und Konsorte. tsss.. |
AW: Property eines TObjects setzen Frage
Zitat:
Delphi-Quellcode:
Aber vielleicht verstehe ich Dich da gerade auch falsch, wäre nicht das erste mal ;)
procedure TfrmMain.ApplyThemedColors;
var i: Integer; begin if IsDarkTheme then begin FBackgroundColor := FColorSet.Colors[ImmersiveApplicationBackgroundDarkTheme]; FTextColor := FColorSet.Colors[ImmersiveApplicationTextDarkTheme]; end else begin FBackgroundColor := FColorSet.Colors[ImmersiveApplicationBackgroundLightTheme]; FTextColor := FColorSet.Colors[ImmersiveApplicationTextLightTheme]; end; UpdateColors; end; |
AW: Property eines TObjects setzen Frage
Zitat:
Ok.. Habe das mal am Beispiel gescheckt da scheint noch einiges im argen zu sein mit der uImmersiveColors Unit. EDIT: Die Fontfarbe der RadioButton kann man nicht ändern ohne OwnerDrawn diese wird von Windows verwaltet. Lösung: Kein Caption angeben und nen Label dahinter setzen. (Oder selber zeichnen) |
AW: Property eines TObjects setzen Frage
Ich mach neuen Thread auf und poste mein schändliches werk, dann kann jeder mit rumspielen und liebend gerne Verbesserungen äußern. Klingt das fair?
Weil sobald ich das manifest theme aktiviere sind ja die externen api commoncontrols an der reihe und pfeifen auf alles was ich einstelle. Warte bitte noch ein paar minuten, ich hab noch was hinzugefügt was den font betrifft. |
AW: Property eines TObjects setzen Frage
Zitat:
Ich bin gerade am aufräumen meines Codes und wollte nun Deinen Vorschlag richtig umsetzen, zur Sicherheit Frage ich nochmal nach ob ich es so anwende wie Du es meintest.
Delphi-Quellcode:
procedure TfrmMain.SetObjectColors(AObject: TObject);
const sPropColor = 'Color'; sPropFont = 'Font'; var Context: TRttiContext; RType: TRttiType; Prop: TRttiProperty; Fields: TRttiField; begin Context := TRttiContext.Create; RType := Context.GetType(AObject.ClassType); for Prop in RType.GetProperties do begin if Prop.Name = sPropColor then Prop.SetValue(AObject, FColorBackground); if Prop.Name = sPropFont then for Fields in RType.GetFields do if Fields.Name = SPropColor then Fields.SetValue(AObject, FColorText); end; Context.Free; end; |
AW: Property eines TObjects setzen Frage
Eventuell eher so:
Delphi-Quellcode:
for Prop in RType.GetProperties do
begin if Prop.Name = sPropColor then Prop.SetValue(AObject, FColorBackground); if Prop.PropertyType.IsInstance and Prop.PropertyType.AsInstance.MetaclassType.InheritsFrom(TFont) and (Prop.Name = sPropFont) then TFont(prop.GetValue(AObject).AsObject).Color := FColorText; end; |
AW: Property eines TObjects setzen Frage
Zitat:
Vielen Dank Uwe! :thumb: //edit Noch eine Frage, wäre
Delphi-Quellcode:
nicht sinnvoller um gleich am Anfang unnützes auszuschließen?
if (Prop.Name = sPropFont) and Prop.PropertyType.IsInstance and Prop.PropertyType.AsInstance.MetaclassType.InheritsFrom(TFont) then
TFont(prop.GetValue(AObject).AsObject).Color := FColorText; |
AW: Property eines TObjects setzen Frage
Kann man machen, ja.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:42 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz