Autor Beitrag
Stread
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Mi 31.12.08 23:36 
Ich habe eine kleine Ampelschaltung. Bei jedem Klick auf den Button ändert es die Farbe also den shape. Kann man das auch so machen dass man nur einmal auf den Button drücken muss und nach 2 sekunden wird es Gelb und nach 4 sekunden dann Grün?

Bisher habe ich:
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:
unit ampel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm17 = class(TForm)
    Rot: TShape;
    Gelb: TShape;
    Gruen: TShape;
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form17: TForm17;

implementation

{$R *.dfm}

procedure TForm17.Button1Click(Sender: TObject);
begin
 if Rot.Visible = true then
begin
   Rot.Visible := false;
   Gelb.Visible := true;
end
 else
  if Gelb.Visible = true then
        begin
         Gelb.Visible := false;
         Gruen.Visible := true;
        end
         else
          if Gruen.Visible = true then
          begin
            Gruen.Visible := false;
            Rot.Visible := true;
          end;
end;

end.



Schönes neues Jahr.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 01.01.09 00:33 
Dafür nimmst du am besten einen Timer, den findest du in der Komponentenpalette unter System. Intervall auf 2000, und in OnTimer (Doppelklick auf die Komponente reicht) den Code schreiben. ;-)

Mit TimerX.Enabled := True / False schaltest du ihn an und aus. Das kannst du anfangs im Objektinspektor auf False setzen und per Button auf True.
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 01.01.09 01:26 
Ich will jetzt nicht ein neues Topic dafür aufmachen weils bestimmt ganz einfach ist. Ich kann plötzlich nichts mehr machen. Nicht dekompilieren nichts um Quelltext schreiben. Das Zeichen ist auch neu.
Einloggen, um Attachments anzusehen!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 01.01.09 01:59 
Ich vermute du hast das Formular statt dem Projekt geöffnet. Denn rechts in der Projektverwaltung ist kein Projekt geöffnet. ;-)
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 01.01.09 02:34 
Komisch ist aber dass es vorher noch nicht da war.
Habe jetzt neues Projekt aufgemacht und die Datei da reingeschoben.
Ergebnis im Bild. Klappt nicht. Muss es wahrscheinlich von vorne beginnen
Einloggen, um Attachments anzusehen!
haentschman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 285
Erhaltene Danke: 33


DX10 Berlin Professional
BeitragVerfasst: Do 01.01.09 23:30 
Hallo...

klicke in der Projektverwaltung mit der RECHTEN Maustaste auf dein Projekt13.exe ---> hinzufügen ---> Deine Unit auswählen und sie ist deinem Projekt hinzugefügt. Dann kannst du auch das ganze compilieren.

hoffe geholfen zu haben... :wave:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 01.01.09 23:34 
Er hatte dafür zwischenzeitlich ein neues Thema für die Frage aufgemacht, das Problem ist bereits gelöst. ;-)
www.delphi-forum.de/viewtopic.php?t=89064