Autor Beitrag
Cookie007
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96

win2000 / Xp / Linux9.3
Delphi7
BeitragVerfasst: Di 31.10.06 15:46 
Hi leute,
Ich will ein Byte Simulieren
Z.B bei eins sol das 1. lämpchen aufleuchen
bei 2. das zweite bei drei die ersten beiden bei 4 das 4. usw

mein Problem das erste Lämpchen bleibt immer aus außer bei 255

hier mein QT
ausblenden volle Höhe 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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
shape1.Brush.Color := clgray;
   shape2.Brush.Color := clgray;
   shape3.Brush.Color := clgray;
   shape4.Brush.Color := clgray;
   shape5.Brush.Color := clgray;
   shape6.Brush.Color := clgray;
   shape7.Brush.Color := clgray;
   shape8.Brush.Color := clgray;


   X := StrToInt(edit1.text);

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape1.Brush.Color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape2.brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape3.Brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape4.Brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape5.Brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape6.Brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape7.Brush.color := clyellow
   else shape1.Brush.color := clgray;

   Y := X mod 2;
   X:= X div 2;
   if Y > 0 then Shape8.brush.color := clyellow
   else shape1.Brush.color := clgray;

   timer1. enabled := false


Danke im vorraus

_________________
Mein System : A64 2400 Clawhammer, 1534 MB Ram, 200GB Festplatte, GeForce 6600 (Gigabyte)
Warum so ein langes Gesicht auf jede Frage gibt es eine Antwort, du musst sie nur suchen.(suchfunktion)
Cookie007 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96

win2000 / Xp / Linux9.3
Delphi7
BeitragVerfasst: Di 31.10.06 15:48 
p.s es liegt wohl daran, dass shape 1 nie über 0 kommt ?????!!!
war nurn gedanke kann auch falsch sein
und nochmal danke im vorraus

_________________
Mein System : A64 2400 Clawhammer, 1534 MB Ram, 200GB Festplatte, GeForce 6600 (Gigabyte)
Warum so ein langes Gesicht auf jede Frage gibt es eine Antwort, du musst sie nur suchen.(suchfunktion)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 31.10.06 15:53 
Guck dir mal an, wo du überall die Zeile shape1.Brush.color := clgray; stehen hast. Und dann überlege, ob Copy&Paste wirklich immer so praktisch ist ;-)

_________________
We are, we were and will not be.
Cookie007 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96

win2000 / Xp / Linux9.3
Delphi7
BeitragVerfasst: Di 31.10.06 15:55 
Dankeschön
und ja mit copy&paste muss an aufpassen
danke thx

_________________
Mein System : A64 2400 Clawhammer, 1534 MB Ram, 200GB Festplatte, GeForce 6600 (Gigabyte)
Warum so ein langes Gesicht auf jede Frage gibt es eine Antwort, du musst sie nur suchen.(suchfunktion)
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Di 31.10.06 16:15 
So ist es 'etwas' kürzer. Es geht noch einfacher, aber so ist es übersichtlich.

ausblenden 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:
Procedure TMyForm.ColorShape (aShape : TShape; aEnable : Boolean);
Begin
  If aEnable Then
    aShape.Brush.Color := clGray
  Else
    aShape.Brush.Color = clYellow
End;

Procedure TMyForm.Button1Click (Sender : TObject);
Var
  B : Byte;

Begin
  B := StrToInt (Edit1.Text);
  ColorShape (Shape1, odd (B));  B := B div 2;
  ColorShape (Shape2, odd (B));  B := B div 2;
  ColorShape (Shape3, odd (B));  B := B div 2;
  ColorShape (Shape4, odd (B));  B := B div 2;
  ColorShape (Shape5, odd (B));  B := B div 2;
  ColorShape (Shape6, odd (B));  B := B div 2;
  ColorShape (Shape7, odd (B));  B := B div 2;
  ColorShape (Shape8, odd (B));  B := B div 2;
End;

_________________
Na denn, dann. Bis dann, denn.