![]() |
Problem mit TControl.Color
Hallo,
ich habe zwar schon die Suche benutzt aber nichts gefunden. Ich nutzte Delphi 7. Warum kann ich einem TControl keine Farbe zuordnen. Ich bekomme die Fehlermeldung "Undefinierter Bezeichner Color". Schaue ich in die Onlinehilfe, ist Color aber eine Eigenschaft von TControl.
Delphi-Quellcode:
var
x: TControl; begin x.color := clBlue; |
Re: Problem mit TControl.Color
Es ist aber eine protected-Eigenschaft.
|
Re: Problem mit TControl.Color
In der Hilfe steht :
Delphi-Quellcode:
Sind Propertys nicht generel Public?
property Color: TColor
|
Re: Problem mit TControl.Color
Nein.
|
Re: Problem mit TControl.Color
Danke erstmal :-D
Hast du auch noch für mich einen kleinen Tipp, wie ich die Farbe von einem unbekannten TControl verändern kann? Ich dachte eigendlich folgendes zu machen :
Delphi-Quellcode:
for i := 0 to MyGroup.ControlCount-1 do
begin MyGroup.Controls[i].Color := clred; end; |
Re: Problem mit TControl.Color
Evtl. per RTTI?
|
Re: Problem mit TControl.Color
Zitat:
Vielleicht solltest Du Dir eine Routine machen, die je nach Control einfärbt.
Delphi-Quellcode:
for i := 0 to MyGroup.ControlCount-1 do
begin if MyGroup.Controls[i] is TLabel then TLabel(MyGroup.Controls[i]).Font.Color := clred; if MyGroup.Controls[i] is TCheckBox then TCheckBox(MyGroup.Controls[i]).Color := clred; // etc. end; |
Re: Problem mit TControl.Color
Mein Beispiel ist auch nur ein Pseudocode. TLabel habe ich schon ausgeklammert. Ich wollte jetzt aber nicht für alle möglichen Controls (Edit, Spin, Checkbox usw.) eine if then Abfrage machen. Das ist mir zu aufwendig :wink: .
|
Re: Problem mit TControl.Color
Delphi-Quellcode:
type
TControlCracker=class(TControl); var x: TControl; begin // der Trick: protected Properties werden so zugänglich TControlCracker(x).color := clBlue; |
Re: Problem mit TControl.Color
Ich finde solch eine Methode zwar beknackt und umständlich :wall:, aber vielen Dank so funktioniert es, so werde ich es machen. Also vielen Dank nochmal. :thumb:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:31 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