Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Alle Buttons auf Panel ansprechen (https://www.delphipraxis.net/74318-alle-buttons-auf-panel-ansprechen.html)

xZise 1. Aug 2006 11:30


Alle Buttons auf Panel ansprechen
 
Ich wollte alle Buttons auf einem Panel ansprechen.
Also habe ich es so versucht:
Delphi-Quellcode:
for i := 0 to xiBg.ComponentCount - 1 do begin
  if xiBg.Components[i] is TXiButton then begin
    with (xiBg.Components[i] as TXiButton) do begin
      ColorBorder := StringToColor(Skin.ReadString('Buttons', 'Border', '$00B35900'));
      ColorDark  := StringToColor(Skin.ReadString('Buttons', 'Dark', '$00FFA851'));
      ColorFace  := StringToColor(Skin.ReadString('Buttons', 'Face', '$00FF953E'));
      ColorFocusRect := StringToColor(Skin.ReadString('Buttons', 'FocusRect', '$00FFA953'));
      ColorGrad  := StringToColor(Skin.ReadString('Buttons', 'Grad', '$00FFB66C'));
      ColorLight    := StringToColor(Skin.ReadString('Buttons', 'Light', '$00FF953E'));
      ColorText := StringToColor(Skin.ReadString('Buttons', 'Text', '$00000000'));
    end;
  end;
Leider funktioniert das so nicht, weil er nicht in die Schleife geht. Und ich bin mir sicher, dass das Panel Komponenten hat!

CK_CK 1. Aug 2006 11:33

Re: Alle Buttons auf Panel ansprechen
 
Gehe doch am besten alle Componenten des Formulars durch (und nicht die des Panels) und dann prüfe, ob als Parent dein Panel gesetzt ist...

(xiBG ist doch ein Panel, oder?)

xZise 1. Aug 2006 11:36

Re: Alle Buttons auf Panel ansprechen
 
xiBg : TXiPanel

ja ist es... Okay dann versuchs ich mal so.

(Das Formular ist übrigends ein Panel, also ist die Parentabfrage nicht nötig.)

[edit]So funktionierts ?! Seltsam... Gibts dafür einen Grund?[/edit]

jbg 1. Aug 2006 11:40

Re: Alle Buttons auf Panel ansprechen
 
Zitat:

Zitat von xZise
[edit]So funktionierts ?! Seltsam... Gibts dafür einen Grund?[/edit]

Ja.
- MyCtrl.Components[] listet alle Komponenten auf, deren Owner MyCtrl ist.
- MyCtrl.Controls[] listet alle Controls auf, deren Parent MyCtrl ist.

Wenn du nun eine Komponente auf das Formular setzt, dann ist der Owner das Formular. Der Parent jedoch das Control, auf dem du die Komponente abgelegt hast. Du musst also in deinem obigen Beispiel Panel.Controls[] durchlaufen und nicht Panel.Components[].

xZise 1. Aug 2006 11:50

Re: Alle Buttons auf Panel ansprechen
 
Achso! Danke... das ist logisch ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:38 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz