![]() |
Alle Komponenten einer Application ändern
Hallo habe folgenden Code gefunden:
Delphi-Quellcode:
Hier werden alle Labels auf Rot gesetzt die im Formular Chatform sind. Ich würde aber gerne alle Labels Programmweit umstellen. Geht das?for I := 0 to chatform.ComponentCount-1 do begin if chatform.Components[I] is TLabel then TLabel(chatform.Components[I]).Font.Color := clred; end; Bei über 23 Formen wird das unübersichtlich jedes einzeln aufzurufen. Danke für die Antworten |
Re: Alle Komponenten einer Application ändern
Moin,
theoretisch müsste das dann gehen, indem du chatform durch Application ersetzt. Kann aber auch sein, dass Du erst alle Komponenten der Application als TForm durchgehen musst und dann von den jeweiligen Forms eben die Labels... |
Re: Alle Komponenten einer Application ändern
Versuch mal statt "chatform" "Application" zu benutzen.
Florian //Edit: :shock: Kein roter Kasten :roll: |
Re: Alle Komponenten einer Application ändern
Zitat:
Am besten im FormCreate für jedes Formular:
Delphi-Quellcode:
edit: Da schon wieder:
for I := 0 to ComponentCount-1 do
if Components(I) is TLabel then TLabel(Components(I)).Font.Color := frmMain.myLabelColor; // als Property Zitat:
|
Re: Alle Komponenten einer Application ändern
Oder halt so:
Delphi-Quellcode:
//Edit: Der "rote Kasten" warnt dich beim Abschicken eines Post, wenn in der Zeit während du geschrieben hast neue Beiträge dazukamen. Dass soll verhindern, dass mehrmals der selbe Vorschlag gepostet wird.
for I := 0 to Application.ComponentCount-1 do
begin if Application.Components(I) is TForm then begin for i2 := 0 to TForm(Application.Components(I)).ComponentCount -1 do TLabel(TForm(Application.Components(I)).Components[i2].Font.Color := clRed; end; end; |
Re: Alle Komponenten einer Application ändern
Zitat:
Sicherheitshalber auch noch nach Label schauen:
Delphi-Quellcode:
for I := 0 to Application.ComponentCount-1 do
begin if Application.Components(I) is TForm then begin for i2 := 0 to TForm(Application.Components(I)).ComponentCount -1 do if TForm(Application.Components(I)).Components[i2] is TLabel then TLabel(TForm(Application.Components(I)).Components[i2].Font.Color := clRed; end; end; |
Re: Alle Komponenten einer Application ändern
Hallo,
habe das hier Probiert:
Delphi-Quellcode:
Aber er zeigt diesen einen Fehler:for I := 0 to Application.ComponentCount-1 do begin if Application.Components[i] is TForm then begin for i2 := 0 to TForm(Application.Components[I]).ComponentCount -1 do TLabel(TForm(Application.Components[I]).Components[i2].Font.Color := clRed; end; end; Zitat:
|
Re: Alle Komponenten einer Application ändern
Hi!
Zitat:
![]() Zitat:
![]() Ciao, Frederic |
Re: Alle Komponenten einer Application ändern
Da fehlt eine Klammer zu ")"
Zitat:
|
Re: Alle Komponenten einer Application ändern
Danke für die Hilfe....
aber bei diesem Code:
Delphi-Quellcode:
bekomme ich lauter Zugriffsverletzungen :-(for I := 0 to Application.ComponentCount-1 do begin if Application.Components[i] is TForm then begin for i2 := 0 to TForm(Application.Components[I]).ComponentCount -1 do TLabel(TForm(Application.Components[I]).Components[i2]).Font.Color := clRed; end; end; danke für die Hilfe |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:43 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