Thema: Delphi Timer

Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#3

Re: Timer

  Alt 26. Aug 2007, 11:06
Delphi-Quellcode:
type
  TAmpelPhase = (
    apRot = 0,
    apRotGelb = 1,
    apGelb = 2,
    apGruen = 3);

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    AktuelleAP: TAmpelPhase;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  AktuelleAP := apRot;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  case AktuelleAP of
    apRot:
    begin
      Caption := 'Rot';
      AktuelleAP := apRotGelb;
    end;
    apRotGelb:
    begin
      Caption := 'RotGelb';
      AktuelleAP := apGruen;
    end;
    apGelb:
    begin
      Caption := 'Gelb';
      AktuelleAP := apRot;
    end;
    apGruen:
    begin
      Caption := 'Grün';
      AktuelleAP := apGelb;
    end;
  end;
end;
Die Farbe wird in der Titelzeile des Fensters als Zeichenkette angezeigt. Ich habe auch gleich noch die rot-gelb Phase mit eingebaut, wie es in der Wirklichkeit auch ist.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat