gih9 - Mo 08.03.04 16:09
Titel: Mehrere Panels schnell verändern
Hallo,
ich hab folgendes Problem. Ich zwölf Panles welche entweder rot oder grün sind, die Farbe hängt vun einem boolean Variable ab. Jede 5 sekunden ändert diese Variable und dann muss ich alle zwölf Panels neu malen. Dazu benutze ich jetzt folgenden code
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
| for i := 1 to 12 do if sgResults.Cells[i,1] = '-1' then begin if i = 1 then begin fDisplay.pError1.Color := clRed; fDisplay.pError1.Caption := '-1' end; if i = 2 then begin fDisplay.pError2.Color := clRed; fDisplay.pError2.Caption := '-1' end; if i = 3 then begin fDisplay.pError3.Color := clRed; fDisplay.pError3.Caption := '-1' end; if i = 4 then begin fDisplay.pError4.Color := clRed; fDisplay.pError4.Caption := '-1' end; . . . |
Der code ist noch länger aber man erkennt hoffentlich das Problem. Meine Frage ist ob und wie man dan vereinfachen könnte. Ungefähr so stell ich mir das vor.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| for i := 1 to 12 do if sgResults.Cells[i,1] = '-1' then begin fDisplay.pError[i].Color := clRed; fDisplay.pError[i].Caption := '-1' end else begin fDisplay.pError[i].Color := clGreen; fDisplay.pError[i].Caption := '0' end; |
Ich weiss dass das nicht funktioniert, ist nur eine Idee wie es gehen könnte.
Das Problem is fast wie bei folgendem Beitrag
http://www.delphi-forum.de/viewtopic.php?t=13929, nur will ich halt das Panel verändern und nicht etwas auslesen.
Danke
gih9
Moderiert von
Motzi: Code- durch Delphi-Tags ersetzt.
gih9 - Mo 08.03.04 16:44
hab's jetzt so gemacht
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24:
| procedure TfOverview.WriteToDisplay; var i : byte; tp:TPanel; begin for i := 1 to 12 do if sgResults.Cells[i,1] = '-1' then begin tp:=FindComponent('pError'+IntToStr(i)) as TPanel; with fDisplay,tp do begin Color:= clRed; Caption := '-1' end end else begin tp:=FindComponent('pError'+IntToStr(i)) as TPanel; with fDisplay,tp do begin Color:= clGreen; Caption := '0' end end end; |
Jetzt hab ich jedoch noch ein anderes Problem und krieg ich bei folgender Zeile
Delphi-Quelltext
1:
| tp:=FindComponent('pError'+IntToStr(i)) as TPanel; |
tp=nil. Das kommt warscheinlich daher dass die Panel auf einer anderen Form sind. Denk ich mal.
Hat da einer ne Idee??
Moderiert von
Motzi: Code- durch Delphi-Tags ersetzt.